mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-21 05:18:39 +01:00
Merge pull request #57 from dylanaraps/gtk2
general: Added GTK2 support.
This commit is contained in:
commit
7f2bc603c3
@ -1,6 +1,7 @@
|
||||
"""
|
||||
Reload programs.
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@ -19,6 +20,24 @@ 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"
|
||||
|
||||
if theme_path.is_dir():
|
||||
if gtk2_file.is_file():
|
||||
shutil.copy(gtk2_file, theme_path / "gtk-2.0")
|
||||
|
||||
# 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():
|
||||
"""Reload i3 colors."""
|
||||
if shutil.which("i3-msg"):
|
||||
@ -34,6 +53,7 @@ def polybar():
|
||||
def env(xrdb_file=None):
|
||||
"""Reload environment."""
|
||||
xrdb(xrdb_file)
|
||||
gtk()
|
||||
i3()
|
||||
polybar()
|
||||
print("reload: Reloaded environment.")
|
||||
|
23
pywal/scripts/gtk_reload.py
Normal file
23
pywal/scripts/gtk_reload.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/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.
|
||||
|
||||
Original source: https://crunchbang.org/forums/viewtopic.php?id=39646
|
||||
"""
|
||||
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()
|
1
pywal/templates/colors-gtk2.rc
Normal file
1
pywal/templates/colors-gtk2.rc
Normal file
@ -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}"
|
Loading…
Reference in New Issue
Block a user