Skip to content

How does ghostty get the system light/dark setting on Linux? #2980

Closed Answered by jcollie
hankertrix asked this question in Q&A
Discussion options

You must be logged in to vote

Ghostty uses the Freedesktop Settings Portal to listen for theme changes.

ghostty/src/apprt/gtk/App.zig

Lines 1116 to 1134 in 6a1df9f

fn initDbus(self: *App) void {
const dbus = c.g_application_get_dbus_connection(@ptrCast(self.app)) orelse {
log.warn("unable to get dbus connection, not setting up events", .{});
return;
};
_ = c.g_dbus_connection_signal_subscribe(
dbus,
null,
"org.freedesktop.portal.Settings",
"SettingChanged",
"/org/freedesktop/portal/desktop",
"org.freedesktop.appearance",
c.G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE,
&gtkNotifyColorScheme,
self,
null,
);
}

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@hankertrix
Comment options

@jcollie
Comment options

@hankertrix
Comment options

@jcollie
Comment options

Answer selected by hankertrix
@hankertrix
Comment options

@jcollie
Comment options

@hankertrix
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants