From dc411bb235993cb4fece314485a83a136eec8b5e Mon Sep 17 00:00:00 2001 From: piotr Date: Wed, 26 Jan 2022 15:17:46 +0100 Subject: [PATCH 01/12] add SwayNC (frontend) --- nwg_panel/main.py | 7 ++ nwg_panel/modules/swaync.py | 136 ++++++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 nwg_panel/modules/swaync.py diff --git a/nwg_panel/main.py b/nwg_panel/main.py index 583025b..6790c2a 100644 --- a/nwg_panel/main.py +++ b/nwg_panel/main.py @@ -43,6 +43,7 @@ from nwg_panel.modules.playerctl import Playerctl from nwg_panel.modules.cpu_avg import CpuAvg from nwg_panel.modules.scratchpad import Scratchpad from nwg_panel.modules.dwl_tags import DwlTags +from nwg_panel.modules.swaync import SwayNC from nwg_panel.modules.menu_start import MenuStart @@ -184,6 +185,12 @@ def instantiate_content(panel, container, content_list, icons_path=""): else: print("'{}' not defined in this panel instance".format(item)) + if item == "swaync": + if item not in panel: + panel[item] = {} + sway_nc = SwayNC(panel[item], icons_path) + container.pack_start(sway_nc, False, False, panel["items-padding"]) + if item == "clock": if item in panel: clock = Clock(panel[item]) diff --git a/nwg_panel/modules/swaync.py b/nwg_panel/modules/swaync.py new file mode 100644 index 0000000..167b5dc --- /dev/null +++ b/nwg_panel/modules/swaync.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 + +from gi.repository import GLib + +import subprocess +import threading + +from nwg_panel.tools import check_key, update_image + +import gi + +gi.require_version('Gtk', '3.0') +gi.require_version('Gdk', '3.0') + +from gi.repository import Gtk, Gdk + + +class SwayNC(Gtk.EventBox): + def __init__(self, settings, icons_path): + self.settings = settings + self.icons_path = icons_path + Gtk.EventBox.__init__(self) + self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) + self.add(self.box) + self.image = Gtk.Image() + self.label = Gtk.Label() + self.icon_path = None + + check_key(settings, "interval", 1) + check_key(settings, "root-css-name", "root-executor") + check_key(settings, "css-name", "") + check_key(settings, "icon-placement", "left") + check_key(settings, "icon-size", 16) + check_key(settings, "tooltip-text", "") + check_key(settings, "on-left-click", "swaync-client -t") + check_key(settings, "on-right-click", "") + check_key(settings, "on-middle-click", "") + check_key(settings, "on-scroll-up", "") + check_key(settings, "on-scroll-down", "") + check_key(settings, "always-show-icon", True) + + update_image(self.image, "view-refresh-symbolic", self.settings["icon-size"], self.icons_path) + + self.set_property("name", settings["root-css-name"]) + + if settings["css-name"]: + self.label.set_property("name", settings["css-name"]) + else: + self.label.set_property("name", "executor-label") + + if settings["tooltip-text"]: + self.set_tooltip_text(settings["tooltip-text"]) + + if settings["on-left-click"] or settings["on-right-click"] or settings["on-middle-click"] or settings[ + "on-scroll-up"] or settings["on-scroll-down"]: + self.connect('button-press-event', self.on_button_press) + self.add_events(Gdk.EventMask.SCROLL_MASK) + self.connect('scroll-event', self.on_scroll) + + self.connect('enter-notify-event', self.on_enter_notify_event) + self.connect('leave-notify-event', self.on_leave_notify_event) + + self.build_box() + self.refresh() + + if settings["interval"] > 0: + Gdk.threads_add_timeout_seconds(GLib.PRIORITY_LOW, settings["interval"], self.refresh) + + def update_widget(self, output): + if output: + try: + num = int(output) + if num > 0 or self.settings["always-show-icon"]: + if not self.icon_path == "bell": + update_image(self.image, "bell", self.settings["icon-size"], self.icons_path) + self.icon_path = "bell" + self.image.show() + if num > 0: + self.label.set_text(str(num)) + self.label.show() + else: + self.label.hide() + except: + update_image(self.image, "view-refresh-symbolic", self.settings["icon-size"], self.icons_path) + self.icon_path = "view-refresh-symbolic" + self.image.show() + + return False + + def get_output(self): + try: + output = subprocess.check_output("swaync-client -c".split()).decode("utf-8") + GLib.idle_add(self.update_widget, output) + except Exception as e: + print(e) + + def refresh(self): + thread = threading.Thread(target=self.get_output) + thread.daemon = True + thread.start() + return True + + def build_box(self): + if self.settings["icon-placement"] == "left": + self.box.pack_start(self.image, False, False, 2) + self.box.pack_start(self.label, False, False, 2) + if self.settings["icon-placement"] != "left": + self.box.pack_start(self.image, False, False, 2) + + def on_enter_notify_event(self, widget, event): + widget.set_state_flags(Gtk.StateFlags.DROP_ACTIVE, clear=False) + widget.set_state_flags(Gtk.StateFlags.SELECTED, clear=False) + + def on_leave_notify_event(self, widget, event): + widget.unset_state_flags(Gtk.StateFlags.DROP_ACTIVE) + widget.unset_state_flags(Gtk.StateFlags.SELECTED) + + def on_button_press(self, widget, event): + if event.button == 1 and self.settings["on-left-click"]: + self.launch(self.settings["on-left-click"]) + elif event.button == 2 and self.settings["on-middle-click"]: + self.launch(self.settings["on-middle-click"]) + elif event.button == 3 and self.settings["on-right-click"]: + self.launch(self.settings["on-right-click"]) + + def on_scroll(self, widget, event): + if event.direction == Gdk.ScrollDirection.UP and self.settings["on-scroll-up"]: + self.launch(self.settings["on-scroll-up"]) + elif event.direction == Gdk.ScrollDirection.DOWN and self.settings["on-scroll-up"]: + self.launch(self.settings["on-scroll-up"]) + else: + print("No command assigned") + + def launch(self, cmd): + print("Executing '{}'".format(cmd)) + subprocess.Popen('exec {}'.format(cmd), shell=True) From 1ba92be0820189898ecaad34b0f47bce1051edd4 Mon Sep 17 00:00:00 2001 From: piotr Date: Wed, 26 Jan 2022 15:32:25 +0100 Subject: [PATCH 02/12] add Glade template --- nwg_panel/glade/config_swaync.glade | 391 ++++++++++++++++++++++++++++ 1 file changed, 391 insertions(+) create mode 100644 nwg_panel/glade/config_swaync.glade diff --git a/nwg_panel/glade/config_swaync.glade b/nwg_panel/glade/config_swaync.glade new file mode 100644 index 0000000..9c6c37d --- /dev/null +++ b/nwg_panel/glade/config_swaync.glade @@ -0,0 +1,391 @@ + + + + + + + True + False + 6 + 12 + + + True + True + + + 1 + 10 + + + + + True + False + start + CSS name + + + 0 + 10 + + + + + True + True + + + 1 + 9 + + + + + True + False + start + Root CSS name + + + 0 + 9 + + + + + True + True + + + 1 + 8 + + + + + True + False + start + On scroll down + + + 0 + 8 + + + + + True + True + + + 1 + 7 + + + + + True + False + start + On scroll up + + + 0 + 7 + + + + + True + True + + + 1 + 6 + + + + + True + False + start + On right click + + + 0 + 6 + + + + + True + True + + + 1 + 5 + + + + + True + False + start + On middle click + + + 0 + 5 + + + + + True + False + start + On left click + + + 0 + 4 + + + + + True + True + + + 1 + 3 + + + + + True + False + start + Tooltip text + + + 0 + 3 + + + + + True + False + returns the number of notifications + start + gtk-about + + + 2 + 2 + + + + + True + False + start + Script + + + 0 + 2 + + + + + True + False + start + Module :: Sway Notification Center + + + + + + 0 + 0 + 3 + + + + + True + True + + + 1 + 13 + + + + + True + False + start + Interval + + + 0 + 13 + + + + + True + False + start + Icon size + + + 0 + 12 + + + + + True + True + + + 1 + 12 + + + + + True + False + start + Icon placement + + + 0 + 11 + + + + + True + False + + left + right + + + + 1 + 11 + + + + + True + False + start + swaync-client -c + + + + + + 1 + 2 + + + + + True + False + start + swaync-client -t + + + + + + 1 + 4 + + + + + Always show icon + True + True + False + start + True + + + 1 + 14 + + + + + True + False + toggles Notification Center on/off + start + gtk-about + + + 2 + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 7fe62ed58379913ba3cc7cfcdfda9c1b84efe22a Mon Sep 17 00:00:00 2001 From: piotr Date: Wed, 26 Jan 2022 15:53:29 +0100 Subject: [PATCH 03/12] add Glade template --- nwg_panel/glade/config_swaync.glade | 2 +- nwg_panel/modules/swaync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nwg_panel/glade/config_swaync.glade b/nwg_panel/glade/config_swaync.glade index 9c6c37d..03970a5 100644 --- a/nwg_panel/glade/config_swaync.glade +++ b/nwg_panel/glade/config_swaync.glade @@ -316,7 +316,7 @@ - + Always show icon True True diff --git a/nwg_panel/modules/swaync.py b/nwg_panel/modules/swaync.py index 167b5dc..73b1762 100644 --- a/nwg_panel/modules/swaync.py +++ b/nwg_panel/modules/swaync.py @@ -28,7 +28,7 @@ class SwayNC(Gtk.EventBox): check_key(settings, "interval", 1) check_key(settings, "root-css-name", "root-executor") - check_key(settings, "css-name", "") + check_key(settings, "css-name", "executor-label") check_key(settings, "icon-placement", "left") check_key(settings, "icon-size", 16) check_key(settings, "tooltip-text", "") From 9414afeaf8caee4154c445216585177aefb1d18f Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 00:23:28 +0100 Subject: [PATCH 04/12] hot fix: add forgotten DwlTags --- nwg_panel/config.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index d1bdfcb..fd95de6 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -448,7 +448,13 @@ class EditorWrapper(object): Gtk.Widget.set_size_request(self.window, 820, 1) - self.known_modules = ["clock", "playerctl", "sway-taskbar", "sway-workspaces", "scratchpad"] + self.known_modules = ["clock", + "playerctl", + "sway-taskbar", + "sway-workspaces", + "scratchpad", + "dwl-tags", + "swaync"] self.scrolled_window = builder.get_object("scrolled-window") From 7b9bacb016141ef83062de3d9abef0f4b49c9155 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 01:01:43 +0100 Subject: [PATCH 05/12] add swaync template --- nwg_panel/config.py | 33 ++ nwg_panel/glade/config_main.glade | 21 +- nwg_panel/glade/config_swaync.glade | 543 ++++++++++++++-------------- 3 files changed, 317 insertions(+), 280 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index fd95de6..8fefc7a 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -495,6 +495,9 @@ class EditorWrapper(object): btn = builder.get_object("btn-scratchpad") btn.connect("clicked", self.edit_scratchpad) + btn = builder.get_object("btn-swaync") + btn.connect("clicked", self.edit_swaync) + btn = builder.get_object("btn-executors") btn.connect("clicked", self.select_executor) @@ -1050,6 +1053,36 @@ class EditorWrapper(object): save_json(self.config, self.file) + def edit_swaync(self, *args): + self.load_panel() + self.edited = "swaync" + check_key(self.panel, "swaync", {}) + settings = self.panel["swaync"] + + defaults = { + "tooltip-text": "Notifications", + "on-left-click": "swaync-client -t", + "on-middle-click": "", + "on-right-click": "", + "on-scroll-up": "", + "on-scroll-down": "", + "root-css-name": "root-executor", + "css-name": "executor", + "icon-placement": "left", + "icon-size": 16, + "interval": 1, + "always-show-icon": True + } + for key in defaults: + check_key(settings, key, defaults[key]) + + builder = Gtk.Builder.new_from_file(os.path.join(dir_name, "glade/config_swaync.glade")) + grid = builder.get_object("grid") + + for item in self.scrolled_window.get_children(): + item.destroy() + self.scrolled_window.add(grid) + def edit_playerctl(self, *args): self.load_panel() self.edited = "playerctl" diff --git a/nwg_panel/glade/config_main.glade b/nwg_panel/glade/config_main.glade index e81152c..dfd5cf8 100644 --- a/nwg_panel/glade/config_main.glade +++ b/nwg_panel/glade/config_main.glade @@ -19,7 +19,7 @@ True False vertical - 7 + 4 Panel @@ -165,6 +165,19 @@ 10 + + + Notification Center + True + True + True + + + False + True + 11 + + Dwl Tags @@ -175,7 +188,7 @@ False True - 11 + 12 @@ -188,7 +201,7 @@ False True - 12 + 13 @@ -201,7 +214,7 @@ False True - 13 + 14 diff --git a/nwg_panel/glade/config_swaync.glade b/nwg_panel/glade/config_swaync.glade index 03970a5..c92d9c9 100644 --- a/nwg_panel/glade/config_swaync.glade +++ b/nwg_panel/glade/config_swaync.glade @@ -2,209 +2,18 @@ - + True False 6 12 - - - True - True - - - 1 - 10 - - True False start - CSS name - - - 0 - 10 - - - - - True - True - - - 1 - 9 - - - - - True - False - start - Root CSS name - - - 0 - 9 - - - - - True - True - - - 1 - 8 - - - - - True - False - start - On scroll down - - - 0 - 8 - - - - - True - True - - - 1 - 7 - - - - - True - False - start - On scroll up - - - 0 - 7 - - - - - True - True - - - 1 - 6 - - - - - True - False - start - On right click - - - 0 - 6 - - - - - True - True - - - 1 - 5 - - - - - True - False - start - On middle click - - - 0 - 5 - - - - - True - False - start - On left click - - - 0 - 4 - - - - - True - True - - - 1 - 3 - - - - - True - False - start - Tooltip text - - - 0 - 3 - - - - - True - False - returns the number of notifications - start - gtk-about - - - 2 - 2 - - - - - True - False - start - Script - - - 0 - 2 - - - - - True - False - start - Module :: Sway Notification Center + Module :: SwayNC @@ -215,74 +24,16 @@ 3 - - - True - True - - - 1 - 13 - - True False start - Interval + Script 0 - 13 - - - - - True - False - start - Icon size - - - 0 - 12 - - - - - True - True - - - 1 - 12 - - - - - True - False - start - Icon placement - - - 0 - 11 - - - - - True - False - - left - right - - - - 1 - 11 + 1 @@ -297,9 +48,56 @@ 1 + 1 + + + + + True + False + returns the number of notifications + start + gtk-about + + + 2 + 1 + + + + + True + False + start + Tooltip text + + + 0 2 + + + True + True + + + 1 + 2 + + + + + True + False + start + On left click + + + 0 + 3 + + True @@ -312,9 +110,224 @@ 1 + 3 + + + + + True + False + toggles Notification Center on/off + start + gtk-about + + + 2 + 3 + + + + + True + False + start + On middle click + + + 0 4 + + + True + True + + + 1 + 4 + + + + + True + False + start + On right click + + + 0 + 5 + + + + + True + True + + + 1 + 5 + + + + + True + False + start + On scroll up + + + 0 + 6 + + + + + True + True + + + 1 + 6 + + + + + True + False + start + On scroll down + + + 0 + 7 + + + + + True + True + + + 1 + 7 + + + + + True + False + start + Root CSS name + + + 0 + 8 + + + + + True + True + + + 1 + 8 + + + + + True + False + start + CSS name + + + 0 + 9 + + + + + True + True + + + 1 + 9 + + + + + True + False + start + Icon placement + + + 0 + 10 + + + + + True + False + + left + right + + + + 1 + 10 + + + + + True + False + start + Icon size + + + 0 + 11 + + + + + True + True + + + 1 + 11 + + + + + True + False + start + Interval + + + 0 + 12 + + + + + True + True + + + 1 + 12 + + Always show icon @@ -326,31 +339,9 @@ 1 - 14 + 13 - - - True - False - toggles Notification Center on/off - start - gtk-about - - - 2 - 4 - - - - - - - - - - - From b08d8e61bcc2fb159ab82c7933a1adca141e4642 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 01:02:20 +0100 Subject: [PATCH 06/12] bump to 0.5.9 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 888c6f9..a53dc15 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(f_name): setup( name='nwg-panel', - version='0.5.8', + version='0.5.9', description='GTK3-based panel for sway window manager', packages=find_packages(), include_package_data=True, From d4cf04f01338d5898bfe0888b8dccc26cc0d3eb4 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 01:55:13 +0100 Subject: [PATCH 07/12] load/save swaync settings --- nwg_panel/config.py | 71 ++++++++++++++++++++++- nwg_panel/glade/config_swaync.glade | 90 ++++++++--------------------- nwg_panel/local/executors.json | 2 +- nwg_panel/main.py | 2 +- nwg_panel/modules/menu_start.py | 2 +- nwg_panel/modules/swaync.py | 2 +- 6 files changed, 97 insertions(+), 72 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 8fefc7a..9f8ea19 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -73,7 +73,7 @@ SKELETON_PANEL: dict = { "margin-right": 0, "margin-top": 0, "padding": 2, - "terminal": "alacritty", + "terminal": "foot", "width": 0 }, "sway-taskbar": { @@ -816,6 +816,8 @@ class EditorWrapper(object): self.update_scratchpad() elif self.edited == "executor": self.update_executor() + elif self.edited == "swaync": + self.update_swaync() elif self.edited == "button": self.update_button() elif self.edited == "modules": @@ -1071,7 +1073,7 @@ class EditorWrapper(object): "icon-placement": "left", "icon-size": 16, "interval": 1, - "always-show-icon": True + "always-show-icon": False } for key in defaults: check_key(settings, key, defaults[key]) @@ -1079,10 +1081,73 @@ class EditorWrapper(object): builder = Gtk.Builder.new_from_file(os.path.join(dir_name, "glade/config_swaync.glade")) grid = builder.get_object("grid") + self.nc_tooltip_text = builder.get_object("tooltip-text") + self.nc_tooltip_text.set_text(settings["tooltip-text"]) + + self.nc_on_middle_click = builder.get_object("on-middle-click") + self.nc_on_middle_click.set_text(settings["on-middle-click"]) + + self.nc_on_right_click = builder.get_object("on-right-click") + self.nc_on_right_click.set_text(settings["on-right-click"]) + + self.nc_on_scroll_up = builder.get_object("on-scroll-up") + self.nc_on_scroll_up.set_text(settings["on-scroll-up"]) + + self.nc_on_scroll_down = builder.get_object("on-scroll-down") + self.nc_on_scroll_down.set_text(settings["on-scroll-down"]) + + self.nc_root_css_name = builder.get_object("root-css-name") + self.nc_root_css_name.set_text(settings["root-css-name"]) + + self.nc_css_name = builder.get_object("css-name") + self.nc_css_name.set_text(settings["css-name"]) + + self.nc_icon_placement = builder.get_object("icon-placement") + self.nc_icon_placement.set_active_id(settings["icon-placement"]) + + self.nc_icon_size = builder.get_object("icon-size") + self.nc_icon_size.set_numeric(True) + adj = Gtk.Adjustment(value=0, lower=8, upper=128, step_increment=1, page_increment=10, page_size=1) + self.nc_icon_size.configure(adj, 1, 0) + self.nc_icon_size.set_value(settings["icon-size"]) + + self.nc_interval = builder.get_object("interval") + self.nc_interval.set_numeric(True) + adj = Gtk.Adjustment(value=0, lower=1, upper=3600, step_increment=1, page_increment=10, page_size=1) + self.nc_interval.configure(adj, 1, 0) + self.nc_interval.set_value(settings["interval"]) + + self.nc_always_show_icon = builder.get_object("always-show-icon") + self.nc_always_show_icon.set_active(settings["always-show-icon"]) + for item in self.scrolled_window.get_children(): item.destroy() self.scrolled_window.add(grid) + def update_swaync(self): + settings = self.panel["swaync"] + + settings["tooltip-text"] = self.nc_tooltip_text.get_text() + settings["on-middle-click"] = self.nc_on_middle_click.get_text() + settings["on-right-click"] = self.nc_on_right_click.get_text() + settings["on-scroll-up"] = self.nc_on_scroll_up.get_text() + settings["on-scroll-down"] = self.nc_on_scroll_down.get_text() + settings["root-css-name"] = self.nc_root_css_name.get_text() + settings["css-name"] = self.nc_css_name.get_text() + + val = self.nc_interval.get_value() + if val is not None: + settings["interval"] = int(val) + + if self.nc_icon_placement.get_active_id(): + settings["icon-placement"] = self.nc_icon_placement.get_active_id() + + settings["icon-size"] = int(self.nc_icon_size.get_value()) + settings["interval"] = int(self.nc_interval.get_value()) + settings["always-show-icon"] = self.nc_always_show_icon.get_active() + + save_json(self.config, self.file) + def edit_playerctl(self, *args): self.load_panel() self.edited = "playerctl" @@ -1264,7 +1329,7 @@ class EditorWrapper(object): "margin-right": 0, "margin-top": 0, "padding": 2, - "terminal": "alacritty", + "terminal": "foot", "width": 0 } for key in defaults: diff --git a/nwg_panel/glade/config_swaync.glade b/nwg_panel/glade/config_swaync.glade index c92d9c9..1784ab3 100644 --- a/nwg_panel/glade/config_swaync.glade +++ b/nwg_panel/glade/config_swaync.glade @@ -2,7 +2,7 @@ - + True False @@ -24,46 +24,6 @@ 3 - - - True - False - start - Script - - - 0 - 1 - - - - - True - False - start - swaync-client -c - - - - - - 1 - 1 - - - - - True - False - returns the number of notifications - start - gtk-about - - - 2 - 1 - - True @@ -73,7 +33,7 @@ 0 - 2 + 1 @@ -83,7 +43,7 @@ 1 - 2 + 1 @@ -95,7 +55,7 @@ 0 - 3 + 2 @@ -110,7 +70,7 @@ 1 - 3 + 2 @@ -123,7 +83,7 @@ 2 - 3 + 2 @@ -135,7 +95,7 @@ 0 - 4 + 3 @@ -145,7 +105,7 @@ 1 - 4 + 3 @@ -157,7 +117,7 @@ 0 - 5 + 4 @@ -167,7 +127,7 @@ 1 - 5 + 4 @@ -179,7 +139,7 @@ 0 - 6 + 5 @@ -189,7 +149,7 @@ 1 - 6 + 5 @@ -201,7 +161,7 @@ 0 - 7 + 6 @@ -211,7 +171,7 @@ 1 - 7 + 6 @@ -223,7 +183,7 @@ 0 - 8 + 7 @@ -233,7 +193,7 @@ 1 - 8 + 7 @@ -245,7 +205,7 @@ 0 - 9 + 8 @@ -255,7 +215,7 @@ 1 - 9 + 8 @@ -267,7 +227,7 @@ 0 - 10 + 9 @@ -281,7 +241,7 @@ 1 - 10 + 9 @@ -293,7 +253,7 @@ 0 - 11 + 10 @@ -303,7 +263,7 @@ 1 - 11 + 10 @@ -315,7 +275,7 @@ 0 - 12 + 11 @@ -325,7 +285,7 @@ 1 - 12 + 11 @@ -339,7 +299,7 @@ 1 - 13 + 12 diff --git a/nwg_panel/local/executors.json b/nwg_panel/local/executors.json index 0cba3cc..a24d141 100644 --- a/nwg_panel/local/executors.json +++ b/nwg_panel/local/executors.json @@ -3,7 +3,7 @@ "script": "gopsuinfo -i a", "interval": 2, "tooltip-text": "CPU average load", - "on-left-click": "alacritty -e htop", + "on-left-click": "foot -e htop", "on-middle-click": "", "on-right-click": "", "on-scroll-up": "", diff --git a/nwg_panel/main.py b/nwg_panel/main.py index 6790c2a..646161e 100644 --- a/nwg_panel/main.py +++ b/nwg_panel/main.py @@ -405,7 +405,7 @@ def main(): "margin-right": 0, "margin-top": 0, "padding": 2, - "terminal": "alacritty", + "terminal": "foot", "width": 0 } for key in defaults: diff --git a/nwg_panel/modules/menu_start.py b/nwg_panel/modules/menu_start.py index c0a54c6..33619a8 100644 --- a/nwg_panel/modules/menu_start.py +++ b/nwg_panel/modules/menu_start.py @@ -61,7 +61,7 @@ class MenuStart(Gtk.Button): cmd += " -o {}".format(self.panel["output"]) if self.settings["padding"] != 2: cmd += " -padding {}".format(self.settings["padding"]) - if self.settings["terminal"] != "alacritty": + if self.settings["terminal"] != "foot": cmd += " -term {}".format(self.settings["terminal"]) if self.panel["position"] != "bottom": cmd += " -va {}".format(self.panel["position"]) diff --git a/nwg_panel/modules/swaync.py b/nwg_panel/modules/swaync.py index 73b1762..a0fe99e 100644 --- a/nwg_panel/modules/swaync.py +++ b/nwg_panel/modules/swaync.py @@ -37,7 +37,7 @@ class SwayNC(Gtk.EventBox): check_key(settings, "on-middle-click", "") check_key(settings, "on-scroll-up", "") check_key(settings, "on-scroll-down", "") - check_key(settings, "always-show-icon", True) + check_key(settings, "always-show-icon", False) update_image(self.image, "view-refresh-symbolic", self.settings["icon-size"], self.icons_path) From e7763c51ef7e961a766be38dfa4356aebe2ad228 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 02:12:22 +0100 Subject: [PATCH 08/12] fix icon visibility --- nwg_panel/modules/swaync.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nwg_panel/modules/swaync.py b/nwg_panel/modules/swaync.py index a0fe99e..4f54b33 100644 --- a/nwg_panel/modules/swaync.py +++ b/nwg_panel/modules/swaync.py @@ -75,6 +75,9 @@ class SwayNC(Gtk.EventBox): update_image(self.image, "bell", self.settings["icon-size"], self.icons_path) self.icon_path = "bell" self.image.show() + else: + self.image.hide() + if num > 0: self.label.set_text(str(num)) self.label.show() From ea5f553a4e2d7b8f4a88b2f7aba80cb5b88fdd93 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 11:42:02 +0100 Subject: [PATCH 09/12] hardcode SwayNC next to Controls --- nwg_panel/config.py | 2 +- nwg_panel/main.py | 16 ++++++++++------ nwg_panel/modules/swaync.py | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 9f8ea19..3b8de19 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -1071,7 +1071,7 @@ class EditorWrapper(object): "root-css-name": "root-executor", "css-name": "executor", "icon-placement": "left", - "icon-size": 16, + "icon-size": 18, "interval": 1, "always-show-icon": False } diff --git a/nwg_panel/main.py b/nwg_panel/main.py index 646161e..01c9236 100644 --- a/nwg_panel/main.py +++ b/nwg_panel/main.py @@ -185,12 +185,6 @@ def instantiate_content(panel, container, content_list, icons_path=""): else: print("'{}' not defined in this panel instance".format(item)) - if item == "swaync": - if item not in panel: - panel[item] = {} - sway_nc = SwayNC(panel[item], icons_path) - container.pack_start(sway_nc, False, False, panel["items-padding"]) - if item == "clock": if item in panel: clock = Clock(panel[item]) @@ -453,6 +447,11 @@ def main(): common.controls_list.append(cc) left_box.pack_start(cc, False, False, 0) + if "swaync" not in panel: + panel["swaync"] = {} + sway_nc = SwayNC(panel["swaync"], icons_path) + left_box.pack_start(sway_nc, False, False, 0) + if panel["menu-start"] == "left": ms = MenuStart(panel, icons_path=icons_path) left_box.pack_start(ms, False, False, 0) @@ -488,6 +487,11 @@ def main(): common.controls_list.append(cc) right_box.pack_end(cc, False, False, 0) + if "swaync" not in panel: + panel["swaync"] = {} + sway_nc = SwayNC(panel["swaync"], icons_path) + right_box.pack_end(sway_nc, False, False, 0) + window.add(vbox) GtkLayerShell.init_for_window(window) diff --git a/nwg_panel/modules/swaync.py b/nwg_panel/modules/swaync.py index 4f54b33..77b2b08 100644 --- a/nwg_panel/modules/swaync.py +++ b/nwg_panel/modules/swaync.py @@ -30,7 +30,7 @@ class SwayNC(Gtk.EventBox): check_key(settings, "root-css-name", "root-executor") check_key(settings, "css-name", "executor-label") check_key(settings, "icon-placement", "left") - check_key(settings, "icon-size", 16) + check_key(settings, "icon-size", 18) check_key(settings, "tooltip-text", "") check_key(settings, "on-left-click", "swaync-client -t") check_key(settings, "on-right-click", "") From 82b4ce1b171538bc409485fc7e1a285cf4667f01 Mon Sep 17 00:00:00 2001 From: piotr Date: Thu, 27 Jan 2022 12:29:20 +0100 Subject: [PATCH 10/12] check if 'swaync' installed --- nwg_panel/common.py | 3 ++- nwg_panel/config.py | 6 +++++- nwg_panel/glade/config_main.glade | 36 +++++++++++++++---------------- nwg_panel/main.py | 18 +++++++++------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/nwg_panel/common.py b/nwg_panel/common.py index 78a4322..9a094aa 100644 --- a/nwg_panel/common.py +++ b/nwg_panel/common.py @@ -28,7 +28,8 @@ commands = { "netifaces": False, "btmgmt": False, "wlr-randr": False, - "upower": False + "upower": False, + "swaync": False } icons_path = "" # "icons_light", "icons_dark" or "" (GTK icons) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 3b8de19..aa449d6 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -496,7 +496,11 @@ class EditorWrapper(object): btn.connect("clicked", self.edit_scratchpad) btn = builder.get_object("btn-swaync") - btn.connect("clicked", self.edit_swaync) + if is_command("swaync"): + btn.connect("clicked", self.edit_swaync) + else: + btn.set_sensitive(False) + btn.set_tooltip_text("The 'swaync' package required") btn = builder.get_object("btn-executors") btn.connect("clicked", self.select_executor) diff --git a/nwg_panel/glade/config_main.glade b/nwg_panel/glade/config_main.glade index dfd5cf8..b64413d 100644 --- a/nwg_panel/glade/config_main.glade +++ b/nwg_panel/glade/config_main.glade @@ -87,6 +87,19 @@ 4 + + + Notifications + True + True + True + + + False + True + 5 + + Menu Start @@ -97,7 +110,7 @@ False True - 5 + 6 @@ -110,7 +123,7 @@ False True - 6 + 7 @@ -123,7 +136,7 @@ False True - 7 + 8 @@ -136,7 +149,7 @@ False True - 8 + 9 @@ -149,7 +162,7 @@ False True - 9 + 10 @@ -159,19 +172,6 @@ True True - - False - True - 10 - - - - - Notification Center - True - True - True - False True diff --git a/nwg_panel/main.py b/nwg_panel/main.py index 01c9236..5ff42f2 100644 --- a/nwg_panel/main.py +++ b/nwg_panel/main.py @@ -447,10 +447,11 @@ def main(): common.controls_list.append(cc) left_box.pack_start(cc, False, False, 0) - if "swaync" not in panel: - panel["swaync"] = {} - sway_nc = SwayNC(panel["swaync"], icons_path) - left_box.pack_start(sway_nc, False, False, 0) + if common.commands["swaync"]: + if "swaync" not in panel: + panel["swaync"] = {} + sway_nc = SwayNC(panel["swaync"], icons_path) + left_box.pack_start(sway_nc, False, False, 0) if panel["menu-start"] == "left": ms = MenuStart(panel, icons_path=icons_path) @@ -487,10 +488,11 @@ def main(): common.controls_list.append(cc) right_box.pack_end(cc, False, False, 0) - if "swaync" not in panel: - panel["swaync"] = {} - sway_nc = SwayNC(panel["swaync"], icons_path) - right_box.pack_end(sway_nc, False, False, 0) + if common.commands["swaync"]: + if "swaync" not in panel: + panel["swaync"] = {} + sway_nc = SwayNC(panel["swaync"], icons_path) + right_box.pack_end(sway_nc, False, False, 0) window.add(vbox) From b6abd646499a7b23d9b1cbf3b45eb19e5dcf6c7c Mon Sep 17 00:00:00 2001 From: piotr Date: Sat, 29 Jan 2022 00:23:53 +0100 Subject: [PATCH 11/12] always show notifications icon (initially) --- nwg_panel/config.py | 2 +- nwg_panel/modules/swaync.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nwg_panel/config.py b/nwg_panel/config.py index aa449d6..49092b7 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -1077,7 +1077,7 @@ class EditorWrapper(object): "icon-placement": "left", "icon-size": 18, "interval": 1, - "always-show-icon": False + "always-show-icon": True } for key in defaults: check_key(settings, key, defaults[key]) diff --git a/nwg_panel/modules/swaync.py b/nwg_panel/modules/swaync.py index 77b2b08..a2f1bfe 100644 --- a/nwg_panel/modules/swaync.py +++ b/nwg_panel/modules/swaync.py @@ -37,7 +37,7 @@ class SwayNC(Gtk.EventBox): check_key(settings, "on-middle-click", "") check_key(settings, "on-scroll-up", "") check_key(settings, "on-scroll-down", "") - check_key(settings, "always-show-icon", False) + check_key(settings, "always-show-icon", True) update_image(self.image, "view-refresh-symbolic", self.settings["icon-size"], self.icons_path) From 2f25d75f38f7e8829b282c387ad3295e7f93aa7f Mon Sep 17 00:00:00 2001 From: piotr Date: Sat, 29 Jan 2022 00:28:51 +0100 Subject: [PATCH 12/12] bump to 0.6.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a53dc15..91c5cfc 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def read(f_name): setup( name='nwg-panel', - version='0.5.9', + version='0.6.0', description='GTK3-based panel for sway window manager', packages=find_packages(), include_package_data=True,