mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-25 17:33:09 +01:00
gtk: Added script to reload GTK themes.
This commit is contained in:
parent
0ec21b4ad2
commit
b3fe4d47ae
@ -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.")
|
||||
|
21
pywal/scripts/gtk_reload.py
Normal file
21
pywal/scripts/gtk_reload.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user