mirror of
https://github.com/anufrievroman/waypaper.git
synced 2024-11-22 07:22:19 +03:00
added new options for swww backed
This commit is contained in:
parent
3464e7671d
commit
a0de759a73
@ -3,6 +3,7 @@
|
||||
GUI wallpaper setter for Wayland and Xorg window managers. It works as a frontend for popular wallpaper backends like `swaybg`, `swww`, `wallutils`, `hyprpaper` and `feh`. See details in [the documentation](https://anufrievroman.gitbook.io/waypaper).
|
||||
|
||||
![screenshot](screenshot.jpg)
|
||||
![screenshot](screenshot2.jpg)
|
||||
|
||||
## Features
|
||||
|
||||
|
BIN
screenshot2.jpg
Normal file
BIN
screenshot2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 MiB |
@ -1,7 +1,9 @@
|
||||
"""Module that runs GUI app"""
|
||||
|
||||
import threading
|
||||
import subprocess
|
||||
import os
|
||||
import time
|
||||
import gi
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
@ -82,6 +84,40 @@ class App(Gtk.Window):
|
||||
def init_ui(self) -> None:
|
||||
"""Initialize the UI elements of the application"""
|
||||
|
||||
# New menus below main menu for swww options
|
||||
self.new_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
|
||||
|
||||
# Create a transition dropdown menu for swww
|
||||
self.swww_transitions_options = Gtk.ComboBoxText()
|
||||
|
||||
# Add content to the new box
|
||||
# Label for swww options
|
||||
|
||||
self.swww_label = Gtk.Label(label="Options for swww: ")
|
||||
# Get angle for animation
|
||||
self.swww_angle_entry = Gtk.Entry()
|
||||
self.swww_angle_entry.set_width_chars(7)
|
||||
self.swww_angle_entry.set_placeholder_text("angle")
|
||||
self.new_box.pack_start(self.swww_angle_entry, False, False, 0)
|
||||
|
||||
# Get steps for animation
|
||||
self.swww_steps_entry = Gtk.Entry()
|
||||
self.swww_steps_entry.set_width_chars(7)
|
||||
self.swww_steps_entry.set_placeholder_text("steps")
|
||||
self.new_box.pack_start(self.swww_steps_entry, False, False, 0)
|
||||
|
||||
# Get duration for animation
|
||||
self.swww_duration_entry = Gtk.Entry()
|
||||
self.swww_duration_entry.set_width_chars(7)
|
||||
self.swww_duration_entry.set_placeholder_text("duration")
|
||||
self.new_box.pack_start(self.swww_duration_entry, False, False, 0)
|
||||
|
||||
# Get fps for animation
|
||||
self.swww_fps_entry = Gtk.Entry()
|
||||
self.swww_fps_entry.set_width_chars(5)
|
||||
self.swww_fps_entry.set_placeholder_text("fps")
|
||||
self.new_box.pack_start(self.swww_fps_entry, False, False, 0)
|
||||
|
||||
# Create a vertical box for layout:
|
||||
self.main_box = Gtk.VBox(spacing=10)
|
||||
self.add(self.main_box)
|
||||
@ -166,7 +202,7 @@ class App(Gtk.Window):
|
||||
self.random_button.set_tooltip_text(self.txt.tip_random)
|
||||
|
||||
# Create a box to contain the bottom row of buttons with margin:
|
||||
self.bottom_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20)
|
||||
self.bottom_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=600)
|
||||
self.bottom_button_box.set_margin_bottom(10)
|
||||
self.main_box.pack_end(self.bottom_button_box, False, False, 0)
|
||||
|
||||
@ -175,16 +211,22 @@ class App(Gtk.Window):
|
||||
self.bottom_loading_box.set_margin_bottom(0)
|
||||
self.main_box.pack_end(self.bottom_loading_box, False, False, 0)
|
||||
|
||||
# Create a box to contain the bottom row of buttons with margin:
|
||||
self.swww_button_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=100)
|
||||
self.swww_button_box.set_margin_bottom(5)
|
||||
self.main_box.pack_start(self.swww_button_box, False, False, 0)
|
||||
|
||||
# Create alignment container for swww:
|
||||
self.swww_row_alignment = Gtk.Alignment(xalign=0.5, yalign=0.0, xscale=0.5, yscale=0.5)
|
||||
self.swww_button_box.pack_start(self.swww_row_alignment, True, False, 0)
|
||||
|
||||
# Create alignment container:
|
||||
self.button_row_alignment = Gtk.Alignment(xalign=0.5, yalign=0.0, xscale=0.5, yscale=0.5)
|
||||
self.bottom_button_box.pack_start(self.button_row_alignment, True, False, 0)
|
||||
|
||||
|
||||
# Create a monitor option dropdown menu:
|
||||
self.monitor_option_combo = Gtk.ComboBoxText()
|
||||
|
||||
# Create a transition dropdown menu for swww
|
||||
self.swww_transitions_options = Gtk.ComboBoxText()
|
||||
|
||||
# Create the options menu button:
|
||||
self.options_button = Gtk.Button(label="Options")
|
||||
self.options_button.connect("clicked", self.on_options_button_clicked)
|
||||
@ -198,8 +240,13 @@ class App(Gtk.Window):
|
||||
self.options_box.pack_end(self.sort_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)
|
||||
# Pack the new box at the end of the main box
|
||||
|
||||
self.swww_transitions_options_display()
|
||||
self.sww_options_box = Gtk.HBox(spacing=10)
|
||||
self.sww_options_box.pack_start(self.new_box, False, False, 0)
|
||||
self.swww_row_alignment.add(self.sww_options_box)
|
||||
|
||||
self.swww_options_display()
|
||||
self.monitor_option_display()
|
||||
self.fill_option_display()
|
||||
self.color_picker_display()
|
||||
@ -260,15 +307,22 @@ class App(Gtk.Window):
|
||||
# Add it to the row of buttons:
|
||||
self.options_box.pack_start(self.monitor_option_combo, False, False, 0)
|
||||
|
||||
def swww_transitions_options_display(self) -> None:
|
||||
def swww_options_display(self) -> None:
|
||||
""" Show swww transition option if backend is swww """
|
||||
self.options_box.remove(self.swww_transitions_options)
|
||||
self.new_box.remove(self.swww_label)
|
||||
self.new_box.remove(self.swww_transitions_options)
|
||||
self.new_box.remove(self.swww_angle_entry)
|
||||
self.new_box.remove(self.swww_steps_entry)
|
||||
self.new_box.remove(self.swww_fps_entry)
|
||||
self.new_box.remove(self.swww_duration_entry)
|
||||
|
||||
if self.cf.backend not in ["swww"]:
|
||||
return
|
||||
|
||||
self.swww_transitions_options = Gtk.ComboBoxText()
|
||||
|
||||
self.swww_transitions_options = Gtk.ComboBoxText()
|
||||
for transitions in SWWW_TRANSITION_TYPES:
|
||||
self.swww_transitions_options.append_text(transitions)
|
||||
|
||||
active_transition = 0
|
||||
if self.cf.swww_transition_type in SWWW_TRANSITION_TYPES:
|
||||
active_transition = SWWW_TRANSITION_TYPES.index(self.cf.swww_transition_type)
|
||||
@ -276,7 +330,12 @@ class App(Gtk.Window):
|
||||
self.swww_transitions_options.connect("changed", self.on_transition_option_changed)
|
||||
self.swww_transitions_options.set_tooltip_text(self.txt.tip_transition)
|
||||
|
||||
self.options_box.pack_start(self.swww_transitions_options, False, False, 0)
|
||||
self.new_box.pack_start(self.swww_label, False, False, 0)
|
||||
self.new_box.pack_start(self.swww_transitions_options, False, False, 0)
|
||||
self.new_box.pack_start(self.swww_angle_entry, False, False, 0)
|
||||
self.new_box.pack_end(self.swww_steps_entry, False, False, 0)
|
||||
self.new_box.pack_end(self.swww_duration_entry, False, False, 0)
|
||||
self.new_box.pack_start(self.swww_fps_entry, False, False, 0)
|
||||
|
||||
def fill_option_display(self):
|
||||
"""Display fill option if backend is not hyprpaper"""
|
||||
@ -479,7 +538,7 @@ class App(Gtk.Window):
|
||||
self.cf.backend = self.backend_option_combo.get_active_text()
|
||||
self.cf.selected_monitor = "All"
|
||||
self.monitor_option_display()
|
||||
self.swww_transitions_options_display()
|
||||
self.swww_options_display()
|
||||
self.fill_option_display()
|
||||
self.color_picker_display()
|
||||
self.show_all()
|
||||
@ -505,6 +564,22 @@ class App(Gtk.Window):
|
||||
|
||||
def on_image_clicked(self, widget, path: str) -> None:
|
||||
"""On clicking an image, set it as a wallpaper and save"""
|
||||
angle = self.swww_angle_entry.get_text()
|
||||
steps = self.swww_steps_entry.get_text()
|
||||
fps = self.swww_fps_entry.get_text()
|
||||
duration = self.swww_duration_entry.get_text()
|
||||
if angle.isdigit():
|
||||
self.cf.swww_transition_angle = angle
|
||||
|
||||
if steps.isdigit():
|
||||
self.cf.swww_transition_step = steps
|
||||
|
||||
if fps.isdigit():
|
||||
self.cf.swww_transition_fps = fps
|
||||
|
||||
if duration.isdigit():
|
||||
self.cf.swww_transition_duration = duration
|
||||
|
||||
self.cf.backend = self.backend_option_combo.get_active_text()
|
||||
self.cf.select_wallpaper(path)
|
||||
self.selected_index = self.image_paths.index(path)
|
||||
|
Loading…
Reference in New Issue
Block a user