From 0ec21b4ad22a0ef62409dd8a02d4cd704a1927ea Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 24 Jul 2017 20:30:01 +1000 Subject: general: Added GTK2 support. --- pywal/templates/colors-gtk2.rc | 1 + 1 file changed, 1 insertion(+) create mode 100644 pywal/templates/colors-gtk2.rc diff --git a/pywal/templates/colors-gtk2.rc b/pywal/templates/colors-gtk2.rc new file mode 100644 index 0000000..b88bb0a --- /dev/null +++ b/pywal/templates/colors-gtk2.rc @@ -0,0 +1 @@ +gtk-color-scheme = "bg_color:{color0}\nfg_color:{color15}\nbase_color:{color0}\ntext_color:{color15}\nselected_bg_color:{color2}\nselected_fg_color:{color0}\ntooltip_bg_color:{color2}\ntooltip_fg_color:{color15}\ntitlebar_bg_color:{color2}\ntitlebar_fg_color:{color15}\nmenubar_bg_color:{color0}\nmenubar_fg_color:{color15}\ntoolbar_bg_color:{color0}\ntoolbar_fg_color:{color15}\nmenu_bg_color:{color0}\nmenu_fg_color:{color15}\npanel_bg_color:{color0}\npanel_fg_color:{color15}\nlink_color:{color2}" -- cgit v1.2.3 From b3fe4d47ae12fba7e43bf849a1d9e13703bf7581 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 24 Jul 2017 21:48:57 +1000 Subject: gtk: Added script to reload GTK themes. --- pywal/reload.py | 21 +++++++++++++++++++++ pywal/scripts/gtk_reload.py | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 pywal/scripts/gtk_reload.py diff --git a/pywal/reload.py b/pywal/reload.py index 322f581..9e4b31e 100644 --- a/pywal/reload.py +++ b/pywal/reload.py @@ -1,6 +1,7 @@ """ Reload programs. """ +import pathlib import re import shutil import subprocess @@ -19,6 +20,25 @@ def xrdb(xrdb_file=None): stderr=subprocess.DEVNULL) +def gtk(): + """Move gtkrc files to the correct location.""" + home = pathlib.Path.home() + theme_path = home / ".themes" / "Flatabulous-wal" + gtk2_file = __cache_dir__ / "colors-gtk2.rc" + gtk3_file = __cache_dir__ / "colors-gtk3.css" + + if theme_path.is_dir(): + if gtk2_file.is_file(): + shutil.copy(gtk2_file, theme_path / "gtk-2.0") + + if gtk3_file.is_file(): + shutil.copy(gtk3_file, theme_path / "gtk-3.0") + + if shutil.which("python2"): + module_dir = pathlib.Path(__file__).parent + util.disown("python2", module_dir / "scripts" / "gtk_reload.py") + + def i3(): """Reload i3 colors.""" if shutil.which("i3-msg"): @@ -34,6 +54,7 @@ def polybar(): def env(xrdb_file=None): """Reload environment.""" xrdb(xrdb_file) + gtk() i3() polybar() print("reload: Reloaded environment.") diff --git a/pywal/scripts/gtk_reload.py b/pywal/scripts/gtk_reload.py new file mode 100644 index 0000000..1377929 --- /dev/null +++ b/pywal/scripts/gtk_reload.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python2 +""" +Small Python 2 script to reload GTK2 themes. + +This uses Python2 since this requires 'send_clientmessage_toall()' +which isn't available in Python 3. +""" +import gtk + + +def gtk_reload(): + """Reload GTK2 themes.""" + events = gtk.gdk.Event(gtk.gdk.CLIENT_EVENT) + data = gtk.gdk.atom_intern("_GTK_READ_RCFILES", False) + events.data_format = 8 + events.send_event = True + events.message_type = data + events.send_clientmessage_toall() + + +gtk_reload() -- cgit v1.2.3 From 609771e695a2cec2ae5e1dd6ef91021cc6b83b71 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 24 Jul 2017 21:56:41 +1000 Subject: reload: Remove GTK3 code and add comment --- pywal/reload.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pywal/reload.py b/pywal/reload.py index 9e4b31e..36c3770 100644 --- a/pywal/reload.py +++ b/pywal/reload.py @@ -25,18 +25,17 @@ def gtk(): home = pathlib.Path.home() theme_path = home / ".themes" / "Flatabulous-wal" gtk2_file = __cache_dir__ / "colors-gtk2.rc" - gtk3_file = __cache_dir__ / "colors-gtk3.css" if theme_path.is_dir(): if gtk2_file.is_file(): shutil.copy(gtk2_file, theme_path / "gtk-2.0") - if gtk3_file.is_file(): - shutil.copy(gtk3_file, theme_path / "gtk-3.0") - - if shutil.which("python2"): - module_dir = pathlib.Path(__file__).parent - util.disown("python2", module_dir / "scripts" / "gtk_reload.py") + # Here we call a Python 2 script to reload the GTK themes. + # This is done because the Python 3 GTK/Gdk libraries don't + # provide a way of doing this. + if shutil.which("python2"): + module_dir = pathlib.Path(__file__).parent + util.disown("python2", module_dir / "scripts" / "gtk_reload.py") def i3(): -- cgit v1.2.3 From 4fecce6e9c326970a73f8f3a599be8a02aeea381 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 24 Jul 2017 21:59:44 +1000 Subject: docs: Add comment --- pywal/scripts/gtk_reload.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pywal/scripts/gtk_reload.py b/pywal/scripts/gtk_reload.py index 1377929..4de7ca3 100644 --- a/pywal/scripts/gtk_reload.py +++ b/pywal/scripts/gtk_reload.py @@ -4,6 +4,8 @@ Small Python 2 script to reload GTK2 themes. This uses Python2 since this requires 'send_clientmessage_toall()' which isn't available in Python 3. + +Original source: https://crunchbang.org/forums/viewtopic.php?id=39646 """ import gtk -- cgit v1.2.3