Compare commits

...

3 Commits

Author SHA1 Message Date
Roman
62e8ed9cfc Unload unused wallpapers in hyprpaper
This is to unload old wallpapers from RAM when the new wallpaper is set, as discussed in #7
2024-05-24 17:23:45 +09:00
Roman
839dd839e2 Kill hyprpaper deamon on swww
Kill the hyprpaper deamon if we switched to swww to avoid the conflict. Discussed in #7
2024-05-24 17:18:21 +09:00
Roman
b066d4e162 Hiding unsopported options on hyprpaper
This hides fill and color options on hyprpaper, as discussed in #7
2024-05-24 17:13:58 +09:00
2 changed files with 26 additions and 7 deletions

View File

@ -178,12 +178,12 @@ class App(Gtk.Window):
self.options_box.pack_end(self.refresh_button, False, False, 0)
self.options_box.pack_end(self.random_button, False, False, 0)
self.options_box.pack_end(self.sort_option_combo, False, False, 0)
self.options_box.pack_end(self.color_picker_button, False, False, 0)
self.options_box.pack_end(self.fill_option_combo, False, False, 0)
self.options_box.pack_start(self.backend_option_combo, False, False, 0)
self.button_row_alignment.add(self.options_box)
self.monitor_option_display()
self.fill_option_display()
self.color_picker_display()
# Connect the "q" key press event to exit the application
self.connect("key-press-event", self.on_key_pressed)
@ -253,7 +253,7 @@ class App(Gtk.Window):
else:
return
# Create a monitor option dropdown menu:
self.monitor_option_combo = Gtk.ComboBoxText()
for monitor in monitor_names:
@ -266,7 +266,17 @@ class App(Gtk.Window):
self.options_box.pack_start(self.monitor_option_combo, False, False, 0)
def fill_option_display(self):
"""Display fill option if backend is not hyprpaper"""
self.options_box.remove(self.fill_option_combo)
if self.cf.backend not in ['hyprpaper', 'none']:
self.options_box.pack_end(self.fill_option_combo, False, False, 0)
def color_picker_display(self):
"""Display color option if backend is not hyprpaper"""
self.options_box.remove(self.color_picker_button)
if self.cf.backend not in ['hyprpaper', 'none']:
self.options_box.pack_end(self.color_picker_button, False, False, 0)
def check_backends(self):
"""Before running the app, check which backends are installed or show the error"""
@ -457,6 +467,8 @@ class App(Gtk.Window):
self.cf.backend = self.backend_option_combo.get_active_text()
self.cf.selected_monitor = "All"
self.monitor_option_display()
self.fill_option_display()
self.color_picker_display()
self.show_all()

View File

@ -34,12 +34,15 @@ def change_wallpaper(image_path, cf, monitor, txt):
"tile": "no",
}
fill = fill_types[cf.fill_option.lower()]
if "swaybg" in cf.installed_backends:
try:
try:
if "swaybg" in cf.installed_backends:
subprocess.Popen(["killall", "swaybg"])
time.sleep(0.005)
except Exception as e:
print(f"{txt.err_kill} {e}")
if "hyprpaper" in cf.installed_backends:
subprocess.Popen(["killall", "hyprpaper"])
time.sleep(0.005)
except Exception as e:
print(f"{txt.err_kill} {e}")
subprocess.Popen(["swww-daemon"])
command = ["swww", "img", image_path]
command.extend(["--resize", fill])
@ -93,8 +96,12 @@ def change_wallpaper(image_path, cf, monitor, txt):
if monitor == "All":
monitor = ""
wallpaper_command = ["hyprctl", "hyprpaper", "wallpaper", f"{monitor},{image_path}"]
unload_command = ["hyprctl", "hyprpaper", "unload", "all"]
subprocess.Popen(preload_command)
time.sleep(0.1)
subprocess.Popen(wallpaper_command)
time.sleep(0.1)
subprocess.Popen(unload_command)
elif cf.backend == "none":
pass