Merge pull request #285 from nwg-piotr/compositor
Run through compositor
This commit is contained in:
@@ -34,6 +34,8 @@ to the labels there's a field with currently focused window details
|
||||
- **Playerctl**: displays an icon and a label of the currently played tune, together with back / play-pause / forward
|
||||
buttons
|
||||
- **Scratchpad**: displays info on current scratchpad content and allows to open scratchpad windows
|
||||
- **SwayMode**: a simple indicator of a sway mode other than "default"
|
||||
- **Tray**: SNI system tray module
|
||||
|
||||
## Installation
|
||||
|
||||
|
@@ -27,7 +27,11 @@ cs_file = os.path.join(config_dir, "common-settings.json")
|
||||
if not os.path.isfile(cs_file):
|
||||
common_settings = {
|
||||
"restart-on-display": True,
|
||||
"restart-delay": 500
|
||||
"restart-delay": 500,
|
||||
"processes-background-only": False,
|
||||
"processes-own-only": True,
|
||||
"processes-interval-ms": 2000,
|
||||
"run-through-compositor": True
|
||||
}
|
||||
save_json(common_settings, cs_file)
|
||||
else:
|
||||
@@ -290,6 +294,7 @@ def build_common_settings_window():
|
||||
check_key(common_settings, "restart-on-display", True)
|
||||
check_key(common_settings, "restart-delay", 500)
|
||||
check_key(common_settings, "processes-interval-ms", 2000)
|
||||
check_key(common_settings, "run-through-compositor", True)
|
||||
|
||||
win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
|
||||
win.set_modal(True)
|
||||
@@ -299,7 +304,7 @@ def build_common_settings_window():
|
||||
win.add(vbox)
|
||||
|
||||
frame = Gtk.Frame()
|
||||
frame.set_label(" nwg-panel: Common settings ")
|
||||
frame.set_label(f" nwg-panel: {voc['common-settings']} ")
|
||||
frame.set_label_align(0.5, 0.5)
|
||||
vbox.pack_start(frame, True, True, 6)
|
||||
|
||||
@@ -309,33 +314,37 @@ def build_common_settings_window():
|
||||
grid.set_row_spacing(6)
|
||||
grid.set_property("margin", 12)
|
||||
|
||||
cb = Gtk.CheckButton.new_with_label("Restart on display connected")
|
||||
cb = Gtk.CheckButton.new_with_label(voc["restart-on-display"])
|
||||
cb.set_active(common_settings["restart-on-display"])
|
||||
cb.connect("toggled", on_restart_check_button)
|
||||
grid.attach(cb, 0, 0, 3, 1)
|
||||
|
||||
lbl = Gtk.Label.new("Restart delay [ms]:")
|
||||
lbl = Gtk.Label.new(f'{voc["restart-delay"]} [ms]:')
|
||||
lbl.set_property("halign", Gtk.Align.END)
|
||||
grid.attach(lbl, 0, 1, 1, 1)
|
||||
|
||||
sb = Gtk.SpinButton.new_with_range(0, 30000, 100)
|
||||
sb.set_value(common_settings["restart-delay"])
|
||||
sb.connect("value-changed", set_int_from_spin_button, "restart-delay")
|
||||
sb.set_tooltip_text("If, after turning a display off and back on, panels don't appear on it, it may mean\n"
|
||||
"the display responds too slowly (e.g. if turned via HDMI). Try increasing this value.")
|
||||
sb.set_tooltip_text(voc["restart-delay-tooltip"])
|
||||
grid.attach(sb, 1, 1, 1, 1)
|
||||
|
||||
lbl = Gtk.Label.new("Processes polling rate [ms]:")
|
||||
lbl = Gtk.Label.new(f'{voc["processes-polling-rate"]} [ms]:')
|
||||
lbl.set_property("halign", Gtk.Align.END)
|
||||
grid.attach(lbl, 0, 2, 1, 1)
|
||||
|
||||
sb = Gtk.SpinButton.new_with_range(0, 30000, 100)
|
||||
sb.set_value(common_settings["processes-interval-ms"])
|
||||
sb.connect("value-changed", set_int_from_spin_button, "processes-interval-ms")
|
||||
sb.set_tooltip_text("Interval for checking data on system processes by the nwg-processes tool.\n"
|
||||
"Default: 2000 ms. Set higher values for slower machines. Set 0 to stop refreshing.")
|
||||
sb.set_tooltip_text(voc["processes-polling-rate-tooltip"])
|
||||
grid.attach(sb, 1, 2, 1, 1)
|
||||
|
||||
cb = Gtk.CheckButton.new_with_label(voc["run-through-compositor"])
|
||||
cb.set_tooltip_text(voc["run-through-compositor-tooltip"])
|
||||
cb.set_active(common_settings["run-through-compositor"])
|
||||
cb.connect("toggled", on_compositor_check_button)
|
||||
grid.attach(cb, 0, 3, 3, 1)
|
||||
|
||||
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
|
||||
vbox.pack_start(hbox, False, False, 6)
|
||||
|
||||
@@ -364,6 +373,11 @@ def on_restart_check_button(cb):
|
||||
common_settings["restart-on-display"] = cb.get_active()
|
||||
|
||||
|
||||
def on_compositor_check_button(cb):
|
||||
global common_settings
|
||||
common_settings["run-through-compositor"] = cb.get_active()
|
||||
|
||||
|
||||
def close_common_settings(btn, window):
|
||||
window.close()
|
||||
|
||||
|
@@ -46,6 +46,7 @@
|
||||
"close-window-when-left": "Close window when left",
|
||||
"command": "Command",
|
||||
"common": "Common",
|
||||
"common-settings": "Common settings",
|
||||
"common-panel-settings": "Common nwg-panel settings",
|
||||
"controls": "Controls",
|
||||
"controls-window-width-tooltip": "Controls window width in pixels; leave 0 for auto.",
|
||||
@@ -165,6 +166,8 @@
|
||||
"pressure": "Pressure",
|
||||
"processes": "Processes",
|
||||
"processes-label-tooltip": "Processes label in the Controls menu",
|
||||
"processes-polling-rate": "Processes polling rate",
|
||||
"processes-polling-rate-tooltip": "Interval for checking data on system processes by the nwg-processes tool. Default: 2000 ms. Set higher values for slower machines. Set 0 to stop refreshing.",
|
||||
"processes-tooltip": "Determines if to display the system processes menu entry.",
|
||||
"readme-tooltip": "Determines if to display the common README browser menu entry.",
|
||||
"readme-label-tooltip": "README label in the Controls menu",
|
||||
@@ -175,8 +178,13 @@
|
||||
"remove-executor": "Remove executor",
|
||||
"remove-panel": "remove panel",
|
||||
"restart-cmd": "Restart command",
|
||||
"restart-delay": "Restart delay",
|
||||
"restart-delay-tooltip": "If, after turning a display off and back on, panels don't appear on it, it may mean the display responds too slowly. Try increasing this value.",
|
||||
"restart-on-display": "Restart on display connected",
|
||||
"right-margin": "Right margin",
|
||||
"root-css-name": "Root CSS name",
|
||||
"run-through-compositor": "Run programs through compositor",
|
||||
"run-through-compositor-tooltip": "Determines if to execute programs via 'swaymsg exec <cmd>' on sway and 'hyprctl dispatch exec <cmd>' on Hyprland",
|
||||
"save-to-database": "Save to database",
|
||||
"script": "Script",
|
||||
"script-tooltip": "Script to execute: should return \nan icon name or path and a label \nin 1 or 2 lines of text. See Wiki \nfor details.",
|
||||
|
@@ -46,6 +46,7 @@
|
||||
"close-window-when-left": "Zamknij opuszczone okno",
|
||||
"command": "Komenda",
|
||||
"common": "Wspólne",
|
||||
"common-settings": "Ustawienia wspólne",
|
||||
"common-panel-settings": "Ustawienia wspólne nwg-panel",
|
||||
"controls": "Kontrolki",
|
||||
"controls-window-width-tooltip": "Szerokość okna modułu Controls w pikselach;\nPozostaw 0 by ustawić automatycznie.",
|
||||
@@ -165,6 +166,8 @@
|
||||
"pressure": "Ciśnienie",
|
||||
"processes": "Procesy",
|
||||
"processes-label-tooltip": "Etykieta procesów w menu modułu Controls",
|
||||
"processes-polling-rate": "Częstotliwość odpytywania procesów",
|
||||
"processes-polling-rate-tooltip": "Interwał odświeżania danych przez narzędzie nwg-processes. Domyślnie: 2000 ms. Używaj większej wartości na wolniejszych maszynach. Ustaw 0 by zatrzymać odświeżanie.",
|
||||
"processes-tooltip": "Określa czy wyświetlać pozycję procesów systemowych w menu.",
|
||||
"readme-tooltip": "Określa czy wyświetlać pozycję przeglądarki README w menu.",
|
||||
"readme-label-tooltip": "Etykieta README w menu modułu Controls",
|
||||
@@ -175,8 +178,13 @@
|
||||
"remove-executor": "Usuń egzekutor",
|
||||
"remove-panel": "Usuń panel",
|
||||
"restart-cmd": "Komenda restartu",
|
||||
"restart-delay": "Opóźnienie restartu",
|
||||
"restart-delay-tooltip": "Jeśli po wyłączeniu i włączniu wyświetlacza panel się na nim nie pojawia, być może wyświetlacz odpowiada zbyt wolno. Spróbuj zwiększyć tę wartość.",
|
||||
"restart-on-display": "Restart po podłączeniu wyświetlacza",
|
||||
"right-margin": "Prawy margines",
|
||||
"root-css-name": "Pierwotna nazwa CSS",
|
||||
"run-through-compositor": "Uruchamiaj programy przez kompozytor",
|
||||
"run-through-compositor-tooltip": "Określa czy uruchamiać programy przez 'swaymsg exec <cmd>' na sway lub 'hyprctl dispatch exec <cmd>' na Hyprland.",
|
||||
"save-to-database": "Zapisz w bazie danych",
|
||||
"script": "Skrypt",
|
||||
"script-tooltip": "Skrypt do wykonania: powinien zwracać nazwę\nlub ścieżkę ikony i tekst, w jednym lub dwóch wierszach.\nWięcej informacji w Wiki.",
|
||||
|
@@ -6,7 +6,8 @@ from gi.repository import GLib
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
from nwg_panel.tools import check_key, eprint, local_dir, load_json, save_json, update_image, update_gtk_entry, create_background_task
|
||||
from nwg_panel.tools import (check_key, eprint, local_dir, load_json, save_json, update_image, update_gtk_entry,
|
||||
create_background_task, cmd_through_compositor)
|
||||
|
||||
import gi
|
||||
|
||||
@@ -153,8 +154,10 @@ class Clock(Gtk.EventBox):
|
||||
print("No command assigned")
|
||||
|
||||
def launch(self, cmd):
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
|
||||
def display_calendar_window(self):
|
||||
if self.popup:
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import gi
|
||||
@@ -10,8 +11,9 @@ gi.require_version('Gdk', '3.0')
|
||||
gi.require_version('GtkLayerShell', '0.1')
|
||||
from gi.repository import Gtk, Gdk, GLib, GtkLayerShell
|
||||
|
||||
from nwg_panel.tools import check_key, get_brightness, set_brightness, get_volume, set_volume, get_battery, \
|
||||
update_image, eprint, list_sinks, toggle_mute, create_background_task, list_sink_inputs, is_command
|
||||
from nwg_panel.tools import (check_key, get_brightness, set_brightness, get_volume, set_volume, get_battery,
|
||||
update_image, eprint, list_sinks, toggle_mute, create_background_task, list_sink_inputs,
|
||||
is_command, cmd_through_compositor)
|
||||
|
||||
from nwg_panel.common import commands
|
||||
|
||||
@@ -771,7 +773,8 @@ class PopupWindow(Gtk.Window):
|
||||
return e
|
||||
|
||||
def launch(self, w, e, cmd):
|
||||
print("Executing '{}'".format(cmd))
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
self.hide()
|
||||
self.bcg_window.hide()
|
||||
|
@@ -2,9 +2,10 @@
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from nwg_panel.tools import check_key, update_image
|
||||
from nwg_panel.tools import check_key, update_image, cmd_through_compositor
|
||||
|
||||
|
||||
class CustomButton(Gtk.Button):
|
||||
@@ -54,7 +55,8 @@ class CustomButton(Gtk.Button):
|
||||
|
||||
def on_click(self, button, cmd):
|
||||
if cmd:
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
else:
|
||||
print("No command assigned")
|
||||
|
@@ -7,7 +7,7 @@ import signal
|
||||
import gi
|
||||
from gi.repository import GLib
|
||||
|
||||
from nwg_panel.tools import check_key, update_image, create_background_task
|
||||
from nwg_panel.tools import check_key, update_image, create_background_task, cmd_through_compositor
|
||||
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gdk', '3.0')
|
||||
@@ -167,5 +167,7 @@ class Executor(Gtk.EventBox):
|
||||
print("No command assigned")
|
||||
|
||||
def launch(self, cmd):
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
|
@@ -4,7 +4,7 @@ from gi.repository import Gtk
|
||||
|
||||
import subprocess
|
||||
|
||||
from nwg_panel.tools import check_key, update_image
|
||||
from nwg_panel.tools import check_key, update_image, cmd_through_compositor
|
||||
|
||||
|
||||
class MenuStart(Gtk.Button):
|
||||
@@ -68,5 +68,7 @@ class MenuStart(Gtk.Button):
|
||||
if self.settings["width"] > 0:
|
||||
cmd += " -width {}".format(self.settings["width"])
|
||||
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
|
@@ -15,8 +15,8 @@ except ModuleNotFoundError:
|
||||
print("You need to install python-requests package", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
from nwg_panel.tools import check_key, eprint, load_json, save_json, temp_dir, file_age, hms, update_image, \
|
||||
get_config_dir, create_background_task
|
||||
from nwg_panel.tools import (check_key, eprint, load_json, save_json, temp_dir, file_age, hms, update_image,
|
||||
get_config_dir, create_background_task, cmd_through_compositor)
|
||||
|
||||
config_dir = get_config_dir()
|
||||
dir_name = os.path.dirname(__file__)
|
||||
@@ -240,8 +240,10 @@ class OpenWeather(Gtk.EventBox):
|
||||
print("No command assigned")
|
||||
|
||||
def launch(self, cmd):
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
|
||||
def get_weather(self):
|
||||
if not os.path.isfile(self.weather_file) or int(file_age(self.weather_file) > self.settings["interval"] - 1):
|
||||
|
@@ -4,7 +4,7 @@ from gi.repository import GLib
|
||||
|
||||
import subprocess
|
||||
|
||||
from nwg_panel.tools import check_key, update_image, create_background_task
|
||||
from nwg_panel.tools import check_key, update_image, create_background_task, cmd_through_compositor
|
||||
|
||||
import gi
|
||||
|
||||
@@ -131,5 +131,7 @@ class SwayNC(Gtk.EventBox):
|
||||
print("No command assigned")
|
||||
|
||||
def launch(self, cmd):
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
cmd = cmd_through_compositor(cmd)
|
||||
|
||||
print(f"Executing: {cmd}")
|
||||
subprocess.Popen('{}'.format(cmd), shell=True)
|
||||
|
@@ -877,3 +877,14 @@ def h_get_activewindow():
|
||||
|
||||
def h_modules_get_all():
|
||||
return h_list_monitors(), h_list_workspaces(), h_list_clients(), h_get_activewindow()
|
||||
|
||||
|
||||
def cmd_through_compositor(cmd):
|
||||
cs_file = os.path.join(get_config_dir(), "common-settings.json")
|
||||
common_settings = load_json(cs_file)
|
||||
if "run-through-compositor" not in common_settings or common_settings["run-through-compositor"] :
|
||||
if os.getenv("SWAYSOCK"):
|
||||
cmd = f"swaymsg exec '{cmd}'"
|
||||
elif os.getenv("HYPRLAND_INSTANCE_SIGNATURE"):
|
||||
cmd = f"hyprctl dispatch exec '{cmd}'"
|
||||
return cmd
|
||||
|
Reference in New Issue
Block a user