Want to contribute code to elementary OS itself? Here are some tips. Looking for documentation on creating your own apps? Please see Getting Started instead.
elementary-sdk from the Terminal:
sudo apt install elementary-sdk
This is a metapackage that depends on several tools we use for development.
dconf Editor is an invaluable tool for seeing and modifying settings. It's installed along with
The GTK Inspector is similar to a web browser's inspector, but for GTK apps. Using the Inspector can greatly speed up development, and allows you view and to test out changing properties without recompiling your app. You can also test out temporary in-app CSS.
First, make sure you have the
elementary-sdk installed. Then enable the Inspector keybinding:
gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true
Focus your app, then launch the Inspector by pressing Ctrl+Shift+I to inspect the widget beneath your cursor, or Ctrl+Shift+D to open the inspector without a widget selected.
You can also run it temporarily together with your app by running:
You can quickly install all known dependencies for a project with
sudo apt build-dep <packagename>
This installs the dependencies for the currently-released version, so it may miss dependencies for unreleased updates. In those cases, refer to the project's README.
You can audit your system for files that have been changed from their originally installed packages:
sudo apt install debsums sudo debsums_init
View changed files:
sudo debsums -cs
View which packages those files belong to:
sudo debsums -c | xargs -rd '\n' -- dpkg -S | cut -d : -f 1 | sort -u
Assuming that you've used
--prefix=/usr when installing custom version you can restore them using:
sudo apt install appname --reinstall
When developing the Panel (codenamed WingPanel) or panel-related packages like the Applications Menu and indicators, you want to start WingPanel from the command line to view logs. WingPanel is automatically started and restarted by Cerbere. To remove WingPanel from its monitored applications:
killall wingpanelto stop the current WingPanel
To restore normal behavior simply enable "Use default value" in dconf Editor. Cerbere will notice this and start to monitor WingPanel again.
Gala is the window manager of elementary OS. If it crashes or freezes during development, it can be nonobvious how to recover. Here's how to do it:
DISPLAY=:0 gala --replace &
If Gala doesn't start, you can reinstall the latest stable version by running
sudo apt install --reinstall gala.
One way to debug applications is logging information in the code. This enables seeing what code was run and what the value of variables where.
Example with arguments:
string name = "Bob"; int age = 30; debug("Person: %s %i", name, age);
debug is a convenience function that calls log with the "debug" log level, there are other less used convenience functions like:
The first argument is the message which is formatted like
printf. This means that it can include "format specifiers" which can be replaced by the remaining arguments you pass to the function. The
%s for example can be replaced by a string, the
%i by an integer. More info.
By default these messages are not shown. To see them you need to set the
G_MESSAGES_DEBUG environment variable to the log domain you're interested in. Usually you'll set it to
all to log everything. More info.
To view logs from all your applications you can use
journalctl. More info.
The GNU Project Debugger (gdb) is a general purpose debugger, but we're mostly going to focus on getting useful information when an application crashes.
runand pressing enter.
backtraceand pressing enter.
(gdb) backtrace, those should provide useful information.
For more information see the manpages by running:
Another tutorial: Debugging with GDB