Skip to content

Instantly share code, notes, and snippets.

@loklaan
Last active September 16, 2015 22:13
Show Gist options
  • Save loklaan/e42ceda6cfca3b9fc09a to your computer and use it in GitHub Desktop.
Save loklaan/e42ceda6cfca3b9fc09a to your computer and use it in GitHub Desktop.
Switch specific Gnome3 applications to GTK Dark Theme, using Devilspie2

Watch applications and apply gnome dark themes

This script is for devilspie2. It will match desired windows by class, and then apply the dark theme on them.

Install

Move specific-dark-theme-applications.lua to ~/.config/devilspie2/.

Edit the desiredWindowClasses variable in the file to change which applications this script matches.

-- Script to run on any new window being opened. Used by devilspie2.
-- Summary: Changes the theme of matching windows to their dark theme variant in GTK3.
-- Note: Modify the `desiredWindowClasses` table to filter for certain appliations.
-- You can also see debugging informtion by running with `devilspie2 --debug`
--
-- Author: loklaan
os = require("os")
desiredWindowClasses = {
Spotify=true,
Atom=true,
Terminator=true
}
debug_print("==== Window Details ====");
debug_print()
debug_print(" XID: " .. get_window_xid())
debug_print(" Window Name: " .. get_window_name())
debug_print(" Window Class: " .. get_window_class())
debug_print()
windowId = get_window_xid()
windowClass = get_window_class()
command = "xprop -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT 'dark' -id " .. windowId
debug_print()
debug_print(" -- Results -- ")
debug_print()
if (desiredWindowClasses[windowClass]) then
debug_print(" Match: " .. windowClass .. " ✓");
debug_print()
debug_print(" Applying dark theme...");
debug_print(" Running command: `" .. command .. "`");
os.execute(command)
debug_print(" Applied dark theme.");
else
debug_print(" Match: No match ✖");
end
debug_print()
debug_print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment