From ce8d1aa4e356544a619510801cd97a8369d40721 Mon Sep 17 00:00:00 2001 From: MoetaYuko Date: Fri, 7 Jul 2023 18:04:14 +0800 Subject: [PATCH 1/3] Remove try-catch inside get_brightness --- nwg_panel/modules/brightness_slider.py | 4 +-- nwg_panel/modules/controls.py | 2 +- nwg_panel/tools.py | 41 ++++++++++---------------- 3 files changed, 19 insertions(+), 28 deletions(-) diff --git a/nwg_panel/modules/brightness_slider.py b/nwg_panel/modules/brightness_slider.py index e2ff47ec..579f6410 100644 --- a/nwg_panel/modules/brightness_slider.py +++ b/nwg_panel/modules/brightness_slider.py @@ -7,7 +7,7 @@ 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, update_image, create_background_task +from nwg_panel.tools import check_key, get_brightness, set_brightness, update_image, create_background_task, eprint class BrightnessSlider(Gtk.EventBox): @@ -92,7 +92,7 @@ def refresh_output(self): controller=self.settings["backlight-controller"]) GLib.idle_add(self.update_brightness) except Exception as e: - print(e) + eprint(e) def update_brightness(self, get=True): icon_name = bri_icon_name(self.bri_value) diff --git a/nwg_panel/modules/controls.py b/nwg_panel/modules/controls.py index 1e0afbfd..b0ddefc2 100644 --- a/nwg_panel/modules/controls.py +++ b/nwg_panel/modules/controls.py @@ -145,7 +145,7 @@ def refresh_output(self): controller=self.settings["backlight-controller"]) GLib.idle_add(self.update_brightness) except Exception as e: - print(e) + eprint(e) if "volume" in self.settings["components"] and (commands["pamixer"] or commands["pactl"]): try: diff --git a/nwg_panel/tools.py b/nwg_panel/tools.py index ade432b9..d11b4ac0 100644 --- a/nwg_panel/tools.py +++ b/nwg_panel/tools.py @@ -524,34 +524,25 @@ def set_volume(percent): def get_brightness(device="", controller=""): brightness = 0 if nwg_panel.common.commands["light"] and controller == "light": - try: - cmd = "light -G -s {}".format(device) if device else "light -G" - output = cmd2string(cmd) - brightness = int(round(float(output), 0)) - except: - pass + cmd = "light -G -s {}".format(device) if device else "light -G" + output = cmd2string(cmd) + brightness = int(round(float(output), 0)) elif nwg_panel.common.commands["brightnessctl"] and controller == "brightnessctl": - try: - cmd = "brightnessctl m -d {}".format(device) if device else "brightnessctl m" - output = cmd2string(cmd) - max_bri = int(output) - - cmd = "brightnessctl g -d {}".format(device) if device else "brightnessctl g" - output = cmd2string(cmd) - b = int(output) * 100 / max_bri - brightness = int(round(float(b), 0)) - except: - pass + cmd = "brightnessctl m -d {}".format(device) if device else "brightnessctl m" + output = cmd2string(cmd) + max_bri = int(output) + + cmd = "brightnessctl g -d {}".format(device) if device else "brightnessctl g" + output = cmd2string(cmd) + b = int(output) * 100 / max_bri + brightness = int(round(float(b), 0)) elif nwg_panel.common.commands["ddcutil"] and controller == "ddcutil": - try: - cmd = "ddcutil getvcp 10 --bus={}".format(device) if device else "ddcutil getvcp 10" - output = cmd2string(cmd) - b = int(output.split("current value =")[1].split(",")[0]) - brightness = int(round(float(b), 0)) - except: - pass + cmd = "ddcutil getvcp 10 --bus={}".format(device) if device else "ddcutil getvcp 10" + output = cmd2string(cmd) + b = int(output.split("current value =")[1].split(",")[0]) + brightness = int(round(float(b), 0)) else: - eprint("Couldn't get brightness, is 'light' or 'brightnessctl' or 'ddcutil' installed?") + raise ValueError("Couldn't get brightness, is 'light' or 'brightnessctl' or 'ddcutil' installed?") return brightness From 65612d1098cedcd0e411b531019e06374762e6a7 Mon Sep 17 00:00:00 2001 From: MoetaYuko Date: Fri, 7 Jul 2023 18:35:00 +0800 Subject: [PATCH 2/3] controls: Remove the bluetooth module Fixes: #237 --- nwg_panel/common.py | 3 +- nwg_panel/config.py | 24 +- nwg_panel/config/config | 4 +- nwg_panel/glade/config_controls.glade | 92 +++----- .../icons_dark/bluetooth-active-symbolic.svg | 206 ------------------ .../bluetooth-disabled-symbolic.svg | 206 ------------------ .../icons_light/bluetooth-active-symbolic.svg | 206 ------------------ .../bluetooth-disabled-symbolic.svg | 206 ------------------ nwg_panel/langs/en_US.json | 2 - nwg_panel/langs/pl_PL.json | 2 - nwg_panel/modules/controls.py | 69 +----- nwg_panel/tools.py | 17 -- 12 files changed, 33 insertions(+), 1004 deletions(-) delete mode 100644 nwg_panel/icons_dark/bluetooth-active-symbolic.svg delete mode 100644 nwg_panel/icons_dark/bluetooth-disabled-symbolic.svg delete mode 100644 nwg_panel/icons_light/bluetooth-active-symbolic.svg delete mode 100644 nwg_panel/icons_light/bluetooth-disabled-symbolic.svg diff --git a/nwg_panel/common.py b/nwg_panel/common.py index f02d10f1..98e328d4 100644 --- a/nwg_panel/common.py +++ b/nwg_panel/common.py @@ -27,9 +27,8 @@ "pactl": False, "playerctl": False, "netifaces": False, - "btmgmt": False, "wlr-randr": False, - "hyprctl":False, + "hyprctl": False, "upower": False, "swaync": False } diff --git a/nwg_panel/config.py b/nwg_panel/config.py index a88315d9..6abe075b 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -68,7 +68,7 @@ "modules-right": [], "controls-settings": { "components": ["net", "brightness", "volume", "battery"], - "commands": {"net": "", "bluetooth": "", "battery": ""}, + "commands": {"net": "", "battery": ""}, "show-values": False, "interval": 1, "icon-size": 16, @@ -3556,15 +3556,6 @@ def edit_controls(self, *args): self.ctrl_comp_net.set_tooltip_text(voc["network-interface-tooltip"]) self.ctrl_comp_net.set_active("net" in settings["components"]) - self.ctrl_comp_bluetooth = builder.get_object("ctrl-comp-bluetooth") - self.ctrl_comp_bluetooth.set_label(voc["bluetooth"]) - self.ctrl_comp_bluetooth.set_tooltip_text(voc["bluetooth-tooltip"]) - if is_command("btmgmt"): - self.ctrl_comp_bluetooth.set_active("bluetooth" in settings["components"]) - else: - self.ctrl_comp_bluetooth.set_active(False) - self.ctrl_comp_bluetooth.set_sensitive(False) - self.ctrl_comp_battery = builder.get_object("ctrl-comp-battery") self.ctrl_comp_battery.set_label(voc["battery"]) self.ctrl_comp_battery.set_tooltip_text(voc["battery-tooltip"]) @@ -3610,11 +3601,6 @@ def edit_controls(self, *args): self.ctrl_net_name.set_placeholder_text(voc["name"]) self.ctrl_net_name.set_text(settings["net-interface"]) - self.ctrl_cdm_bluetooth = builder.get_object("ctrl-cmd-bluetooth") - self.ctrl_cdm_bluetooth.set_placeholder_text(voc["on-click-command"]) - check_key(settings["commands"], "bluetooth", "") - self.ctrl_cdm_bluetooth.set_text(settings["commands"]["bluetooth"]) - self.ctrl_cdm_battery = builder.get_object("ctrl-cmd-battery") self.ctrl_cdm_battery.set_placeholder_text(voc["on-click-command"]) check_key(settings["commands"], "battery", "") @@ -3720,13 +3706,6 @@ def update_controls(self): if "net" in settings["components"]: settings["components"].remove("net") - if self.ctrl_comp_bluetooth.get_active(): - if "bluetooth" not in settings["components"]: - settings["components"].append("bluetooth") - else: - if "bluetooth" in settings["components"]: - settings["components"].remove("bluetooth") - if self.ctrl_comp_battery.get_active(): if "battery" not in settings["components"]: settings["components"].append("battery") @@ -3743,7 +3722,6 @@ def update_controls(self): settings["commands"]["net"] = self.ctrl_cdm_net.get_text() settings["net-interface"] = self.ctrl_net_name.get_text() - settings["commands"]["bluetooth"] = self.ctrl_cdm_bluetooth.get_text() settings["commands"]["battery"] = self.ctrl_cdm_battery.get_text() settings["processes-label"] = self.ctrl_comp_processes_label.get_text() settings["root-css-name"] = self.ctrl_root_css_name.get_text() diff --git a/nwg_panel/config/config b/nwg_panel/config/config index df11e4bf..981b0c96 100644 --- a/nwg_panel/config/config +++ b/nwg_panel/config/config @@ -32,7 +32,6 @@ ], "commands": { "net": "", - "bluetooth": "", "battery": "" }, "show-values": false, @@ -174,7 +173,6 @@ ], "commands": { "net": "", - "bluetooth": "", "battery": "" }, "show-values": false, @@ -268,4 +266,4 @@ "on-scroll-down": "" } } -] \ No newline at end of file +] diff --git a/nwg_panel/glade/config_controls.glade b/nwg_panel/glade/config_controls.glade index 5124bfc6..a1cf22da 100644 --- a/nwg_panel/glade/config_controls.glade +++ b/nwg_panel/glade/config_controls.glade @@ -8,7 +8,7 @@ 0.5 out - + True False @@ -123,31 +123,6 @@ 2 - - - Bluetooth - True - True - False - start - True - - - 0 - 3 - - - - - True - True - on click command - - - 2 - 3 - - Battery @@ -159,7 +134,7 @@ 0 - 4 + 3 @@ -170,7 +145,7 @@ 2 - 4 + 3 @@ -182,7 +157,7 @@ 0 - 5 + 4 @@ -192,7 +167,7 @@ 2 - 5 + 4 @@ -207,7 +182,7 @@ values in the panel widget 0 - 16 + 15 @@ -219,7 +194,7 @@ values in the panel widget 0 - 15 + 14 @@ -236,7 +211,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 15 + 14 @@ -248,7 +223,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 14 + 13 @@ -258,7 +233,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 14 + 13 @@ -270,7 +245,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 13 + 12 @@ -280,7 +255,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 13 + 12 @@ -292,7 +267,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 12 + 11 @@ -302,7 +277,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 12 + 11 @@ -314,7 +289,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 11 + 10 @@ -324,7 +299,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 11 + 10 @@ -336,7 +311,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 10 + 9 @@ -346,7 +321,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 10 + 9 @@ -358,7 +333,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 9 + 8 @@ -369,7 +344,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 9 + 8 @@ -381,7 +356,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 8 + 7 @@ -392,7 +367,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 8 + 7 @@ -406,7 +381,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 7 + 6 @@ -418,7 +393,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 6 + 5 @@ -428,7 +403,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 6 + 5 @@ -439,7 +414,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 7 + 6 @@ -454,7 +429,7 @@ window when left 0 - 17 + 16 @@ -469,7 +444,7 @@ window on mouse click outside it 2 - 17 + 16 @@ -484,7 +459,7 @@ on panel Controls widget pointed 2 - 16 + 15 @@ -634,15 +609,6 @@ on panel Controls widget pointed - - - - - - - - - diff --git a/nwg_panel/icons_dark/bluetooth-active-symbolic.svg b/nwg_panel/icons_dark/bluetooth-active-symbolic.svg deleted file mode 100644 index 6521c5d3..00000000 --- a/nwg_panel/icons_dark/bluetooth-active-symbolic.svg +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/icons_dark/bluetooth-disabled-symbolic.svg b/nwg_panel/icons_dark/bluetooth-disabled-symbolic.svg deleted file mode 100644 index e41de613..00000000 --- a/nwg_panel/icons_dark/bluetooth-disabled-symbolic.svg +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/icons_light/bluetooth-active-symbolic.svg b/nwg_panel/icons_light/bluetooth-active-symbolic.svg deleted file mode 100644 index 8ec4a698..00000000 --- a/nwg_panel/icons_light/bluetooth-active-symbolic.svg +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/icons_light/bluetooth-disabled-symbolic.svg b/nwg_panel/icons_light/bluetooth-disabled-symbolic.svg deleted file mode 100644 index 541b3cb6..00000000 --- a/nwg_panel/icons_light/bluetooth-disabled-symbolic.svg +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/langs/en_US.json b/nwg_panel/langs/en_US.json index 129c49ad..e228de0e 100644 --- a/nwg_panel/langs/en_US.json +++ b/nwg_panel/langs/en_US.json @@ -24,8 +24,6 @@ "battery-low-check-tooltip": "Set 0 to disable.", "battery-low-notification": "Battery low notification at [%]", "battery-tooltip": "Depends on `python-psutil`.", - "bluetooth": "Bluetooth", - "bluetooth-tooltip": "Depends on `bluez-utils`.", "bottom-margin": "Bottom margin", "brightness": "Brightness", "brightness-slider": "Brightness slider", diff --git a/nwg_panel/langs/pl_PL.json b/nwg_panel/langs/pl_PL.json index e2f48276..a605b04d 100644 --- a/nwg_panel/langs/pl_PL.json +++ b/nwg_panel/langs/pl_PL.json @@ -24,8 +24,6 @@ "battery-low-check-tooltip": "Ustaw 0 by wyłączyć.", "battery-low-notification": "Alarmuj o słabej baterii przy [%]", "battery-tooltip": "Zależy od paczki `python-psutil`.", - "bluetooth": "Bluetooth", - "bluetooth-tooltip": "Zależy od paczki `bluez-utils`.", "bottom-margin": "Margines dolny", "brightness": "Jasność", "brightness-slider": "Suwak jasności", diff --git a/nwg_panel/modules/controls.py b/nwg_panel/modules/controls.py index b0ddefc2..41194083 100644 --- a/nwg_panel/modules/controls.py +++ b/nwg_panel/modules/controls.py @@ -11,7 +11,7 @@ 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, \ - get_interface, update_image, bt_info, eprint, list_sinks, toggle_mute, create_background_task + get_interface, update_image, eprint, list_sinks, toggle_mute, create_background_task from nwg_panel.common import commands @@ -61,11 +61,6 @@ def __init__(self, settings, position, alignment, width, monitor=None, icons_pat self.vol_value = 0 self.vol_muted = False - self.bt_icon_name = "view-refresh-symbolic" - self.bt_image = Gtk.Image.new_from_icon_name(self.bt_icon_name, Gtk.IconSize.MENU) - self.bt_label = Gtk.Label() if settings["show-values"] else None - self.bt_name = "" - self.bat_icon_name = "view-refresh-symbolic" self.bat_image = Gtk.Image.new_from_icon_name(self.bat_icon_name, Gtk.IconSize.MENU) self.bat_label = Gtk.Label() if settings["show-values"] else None @@ -116,11 +111,6 @@ def build_box(self): else: print("'netifaces' python module not found") - if "bluetooth" in self.settings["components"] and commands["btmgmt"]: - box.pack_start(self.bt_image, False, False, 4) - if self.bt_label: - box.pack_start(self.bt_label, False, False, 0) - if "battery" in self.settings["components"]: box.pack_start(self.bat_image, False, False, 4) if self.bat_label: @@ -133,11 +123,6 @@ def refresh_output(self): self.net_ip_addr = get_interface(self.settings["net-interface"]) GLib.idle_add(self.update_net, self.net_ip_addr) - if commands["btmgmt"]: - name, powered = bt_info() - if "bluetooth" in self.settings["components"]: - GLib.idle_add(self.update_bt, name, powered) - if "brightness" in self.settings["components"]: try: self.bri_value = get_brightness( @@ -179,16 +164,6 @@ def update_net(self, ip): if self.net_label: self.net_label.set_text("{}".format(self.settings["net-interface"])) - def update_bt(self, name, powered): - icon_name = "bluetooth-active-symbolic" if powered else "bluetooth-disabled-symbolic" - if icon_name != self.bt_icon_name: - update_image(self.bt_image, icon_name, self.icon_size, self.icons_path) - self.bt_icon_name = icon_name - - self.bt_name = name - if self.bt_label: - self.bt_label.set_text(name) - def update_brightness(self, get=True): icon_name = bri_icon_name(self.bri_value) @@ -482,34 +457,6 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i event_box.add(inner_vbox) - if "bluetooth" in settings["components"] and commands["btmgmt"]: - event_box = Gtk.EventBox() - if "bluetooth" in settings["commands"] and settings["commands"]["bluetooth"]: - event_box.connect("enter_notify_event", self.on_enter_notify_event) - event_box.connect("leave_notify_event", self.on_leave_notify_event) - - event_box.connect('button-press-event', self.launch, settings["commands"]["bluetooth"]) - - inner_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) - inner_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) - inner_vbox.pack_start(inner_hbox, True, True, 6) - v_box.pack_start(event_box, True, True, 0) - - self.bt_icon_name = "view-refresh-symbolic" - self.bt_image = Gtk.Image.new_from_icon_name(self.bt_icon_name, Gtk.IconSize.MENU) - - inner_hbox.pack_start(self.bt_image, False, False, 6) - - self.bt_label = Gtk.Label() - inner_hbox.pack_start(self.bt_label, False, True, 6) - - if "bluetooth" in settings["commands"] and settings["commands"]["bluetooth"]: - img = Gtk.Image() - update_image(img, "pan-end-symbolic", self.icon_size, self.icons_path) - inner_hbox.pack_end(img, False, True, 4) - - event_box.add(inner_vbox) - if "battery" in settings["components"]: event_box = Gtk.EventBox() if "battery" in settings["commands"] and settings["commands"]["battery"]: @@ -707,14 +654,6 @@ def refresh(self, *args): ip_addr = "disconnected" if not self.parent.net_ip_addr else self.parent.net_ip_addr self.net_label.set_text("{}: {}".format(self.settings["net-interface"], ip_addr)) - if "bluetooth" in self.settings["components"] and commands["btmgmt"]: - if self.parent.bt_icon_name != self.bt_icon_name: - update_image(self.bt_image, self.parent.bt_icon_name, self.icon_size, self.icons_path) - self.bt_icon_name = self.parent.bt_icon_name - - if self.bt_label: - self.bt_label.set_text(self.parent.bt_name) - if "battery" in self.settings["components"]: if self.parent.bat_icon_name != self.bat_icon_name: update_image(self.bat_image, self.parent.bat_icon_name, self.icon_size, self.icons_path) @@ -895,9 +834,3 @@ def bat_icon_name(value, is_charging): icon_name = "battery-low-symbolic" return icon_name - - -def bt_icon_name(is_on): - icon_name = "bluetooth-active-symbolic" if is_on else "bluetooth-disabled-symbolic" - - return icon_name diff --git a/nwg_panel/tools.py b/nwg_panel/tools.py index d11b4ac0..0a7e5ebb 100644 --- a/nwg_panel/tools.py +++ b/nwg_panel/tools.py @@ -697,23 +697,6 @@ def create_pixbuf(icon_name, icon_size, icons_path="", fallback=True): return pixbuf -def bt_info(): - name, powered = "", False - try: - info = subprocess.check_output("btmgmt info", shell=True).decode("utf-8").strip().splitlines() - for line in info: - if "current settings" in line: - if "powered" in line: - powered = True - continue - if "name" in line and "short" not in line: - name = line.split("name")[1].strip() - except: - pass - - return name, powered - - def list_configs(config_dir): configs = {} # allow to store json files other than panel config files in the config directory From 810eb3435497d7b081b0eeee75f3244bfa34e47b Mon Sep 17 00:00:00 2001 From: MoetaYuko Date: Sun, 9 Jul 2023 15:04:19 +0800 Subject: [PATCH 3/3] controls: Remove the network module --- nwg_panel/common.py | 1 - nwg_panel/config.py | 30 +-- nwg_panel/config/config | 5 - nwg_panel/glade/config_controls.glade | 101 +++----- .../network-wired-disconnected-symbolic.svg | 63 ----- .../icons_dark/network-wired-symbolic.svg | 63 ----- .../network-wireless-connected-symbolic.svg | 221 ------------------ ...network-wireless-disconnected-symbolic.svg | 221 ------------------ .../network-wired-disconnected-symbolic.svg | 63 ----- .../icons_light/network-wired-symbolic.svg | 63 ----- .../network-wireless-connected-symbolic.svg | 221 ------------------ ...network-wireless-disconnected-symbolic.svg | 221 ------------------ nwg_panel/langs/en_US.json | 2 - nwg_panel/langs/pl_PL.json | 2 - nwg_panel/modules/controls.py | 74 +----- nwg_panel/tools.py | 21 -- 16 files changed, 33 insertions(+), 1339 deletions(-) delete mode 100644 nwg_panel/icons_dark/network-wired-disconnected-symbolic.svg delete mode 100644 nwg_panel/icons_dark/network-wired-symbolic.svg delete mode 100644 nwg_panel/icons_dark/network-wireless-connected-symbolic.svg delete mode 100644 nwg_panel/icons_dark/network-wireless-disconnected-symbolic.svg delete mode 100644 nwg_panel/icons_light/network-wired-disconnected-symbolic.svg delete mode 100644 nwg_panel/icons_light/network-wired-symbolic.svg delete mode 100644 nwg_panel/icons_light/network-wireless-connected-symbolic.svg delete mode 100644 nwg_panel/icons_light/network-wireless-disconnected-symbolic.svg diff --git a/nwg_panel/common.py b/nwg_panel/common.py index 98e328d4..482652e2 100644 --- a/nwg_panel/common.py +++ b/nwg_panel/common.py @@ -26,7 +26,6 @@ "pamixer": False, "pactl": False, "playerctl": False, - "netifaces": False, "wlr-randr": False, "hyprctl": False, "upower": False, diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 6abe075b..d50dd5f0 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -67,8 +67,8 @@ "modules-center": [], "modules-right": [], "controls-settings": { - "components": ["net", "brightness", "volume", "battery"], - "commands": {"net": "", "battery": ""}, + "components": ["brightness", "volume", "battery"], + "commands": {"battery": ""}, "show-values": False, "interval": 1, "icon-size": 16, @@ -77,7 +77,6 @@ "click-closes": False, "root-css-name": "controls-overview", "css-name": "controls-window", - "net-interface": "", "battery-low-level": 20, "battery-low-interval": 3, "custom-items": [{"name": "Panel settings", "icon": "nwg-panel", "cmd": "nwg-panel-config"}], @@ -3463,7 +3462,6 @@ def edit_controls(self, *args): settings = self.panel["controls-settings"] defaults = { "components": [ - "net", "brightness", "volume", "battery", @@ -3485,7 +3483,6 @@ def edit_controls(self, *args): "click-closes": False, "root-css-name": "controls-overview", "css-name": "controls-window", - "net-interface": "", "battery-low-level": 20, "battery-low-interval": 3, "processes-label": voc["processes"], @@ -3551,11 +3548,6 @@ def edit_controls(self, *args): self.ctrl_comp_switcher.set_sensitive(is_command("pamixer")) self.ctrl_comp_switcher.set_active(settings["output-switcher"]) - self.ctrl_comp_net = builder.get_object("ctrl-comp-net") - self.ctrl_comp_net.set_label(voc["network-interface"]) - self.ctrl_comp_net.set_tooltip_text(voc["network-interface-tooltip"]) - self.ctrl_comp_net.set_active("net" in settings["components"]) - self.ctrl_comp_battery = builder.get_object("ctrl-comp-battery") self.ctrl_comp_battery.set_label(voc["battery"]) self.ctrl_comp_battery.set_tooltip_text(voc["battery-tooltip"]) @@ -3592,15 +3584,6 @@ def edit_controls(self, *args): lbl = builder.get_object("lbl-css-name") lbl.set_text("{}:".format(voc["css-name"])) - self.ctrl_cdm_net = builder.get_object("ctrl-cmd-net") - self.ctrl_cdm_net.set_placeholder_text(voc["on-click-command"]) - check_key(settings["commands"], "net", "") - self.ctrl_cdm_net.set_text(settings["commands"]["net"]) - - self.ctrl_net_name = builder.get_object("ctrl-net-name") - self.ctrl_net_name.set_placeholder_text(voc["name"]) - self.ctrl_net_name.set_text(settings["net-interface"]) - self.ctrl_cdm_battery = builder.get_object("ctrl-cmd-battery") self.ctrl_cdm_battery.set_placeholder_text(voc["on-click-command"]) check_key(settings["commands"], "battery", "") @@ -3699,13 +3682,6 @@ def update_controls(self): settings["output-switcher"] = self.ctrl_comp_switcher.get_active() - if self.ctrl_comp_net.get_active(): - if "net" not in settings["components"]: - settings["components"].append("net") - else: - if "net" in settings["components"]: - settings["components"].remove("net") - if self.ctrl_comp_battery.get_active(): if "battery" not in settings["components"]: settings["components"].append("battery") @@ -3720,8 +3696,6 @@ def update_controls(self): if "processes" in settings["components"]: settings["components"].remove("processes") - settings["commands"]["net"] = self.ctrl_cdm_net.get_text() - settings["net-interface"] = self.ctrl_net_name.get_text() settings["commands"]["battery"] = self.ctrl_cdm_battery.get_text() settings["processes-label"] = self.ctrl_comp_processes_label.get_text() settings["root-css-name"] = self.ctrl_root_css_name.get_text() diff --git a/nwg_panel/config/config b/nwg_panel/config/config index 981b0c96..4659b823 100644 --- a/nwg_panel/config/config +++ b/nwg_panel/config/config @@ -31,7 +31,6 @@ "battery" ], "commands": { - "net": "", "battery": "" }, "show-values": false, @@ -41,7 +40,6 @@ "leave-closes": true, "click-closes": false, "css-name": "controls-window", - "net-interface": "", "custom-items": [ { "name": "Panel settings", @@ -166,13 +164,11 @@ ], "controls-settings": { "components": [ - "net", "brightness", "volume", "battery" ], "commands": { - "net": "", "battery": "" }, "show-values": false, @@ -182,7 +178,6 @@ "leave-closes": true, "click-closes": false, "css-name": "controls-window", - "net-interface": "", "custom-items": [ { "name": "Panel settings", diff --git a/nwg_panel/glade/config_controls.glade b/nwg_panel/glade/config_controls.glade index a1cf22da..dc0f0f09 100644 --- a/nwg_panel/glade/config_controls.glade +++ b/nwg_panel/glade/config_controls.glade @@ -8,7 +8,7 @@ 0.5 out - + True False @@ -86,43 +86,6 @@ 1 - - - Interface - True - True - False - start - True - - - 0 - 2 - - - - - True - True - on click command - - - 2 - 2 - - - - - True - True - 6 - name - - - 3 - 2 - - Battery @@ -134,7 +97,7 @@ 0 - 3 + 2 @@ -145,7 +108,7 @@ 2 - 3 + 2 @@ -157,7 +120,7 @@ 0 - 4 + 3 @@ -167,7 +130,7 @@ 2 - 4 + 3 @@ -182,7 +145,7 @@ values in the panel widget 0 - 15 + 14 @@ -194,7 +157,7 @@ values in the panel widget 0 - 14 + 13 @@ -211,7 +174,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 14 + 13 @@ -223,7 +186,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 13 + 12 @@ -233,7 +196,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 13 + 12 @@ -245,7 +208,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 12 + 11 @@ -255,7 +218,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 12 + 11 @@ -267,7 +230,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 11 + 10 @@ -277,7 +240,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 11 + 10 @@ -289,7 +252,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 10 + 9 @@ -299,7 +262,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 10 + 9 @@ -311,7 +274,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 9 + 8 @@ -321,7 +284,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 9 + 8 @@ -333,7 +296,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 8 + 7 @@ -344,7 +307,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 8 + 7 @@ -356,7 +319,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 7 + 6 @@ -367,7 +330,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 7 + 6 @@ -381,7 +344,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 6 + 5 @@ -393,7 +356,7 @@ the horizontal, in degrees, measured counterclockwise 0 - 5 + 4 @@ -403,7 +366,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 5 + 4 @@ -414,7 +377,7 @@ the horizontal, in degrees, measured counterclockwise 2 - 6 + 5 @@ -429,7 +392,7 @@ window when left 0 - 16 + 15 @@ -444,7 +407,7 @@ window on mouse click outside it 2 - 16 + 15 @@ -459,7 +422,7 @@ on panel Controls widget pointed 2 - 15 + 14 @@ -603,12 +566,6 @@ on panel Controls widget pointed - - - - - - diff --git a/nwg_panel/icons_dark/network-wired-disconnected-symbolic.svg b/nwg_panel/icons_dark/network-wired-disconnected-symbolic.svg deleted file mode 100644 index 24c2f696..00000000 --- a/nwg_panel/icons_dark/network-wired-disconnected-symbolic.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/nwg_panel/icons_dark/network-wired-symbolic.svg b/nwg_panel/icons_dark/network-wired-symbolic.svg deleted file mode 100644 index 06bf8fb9..00000000 --- a/nwg_panel/icons_dark/network-wired-symbolic.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/nwg_panel/icons_dark/network-wireless-connected-symbolic.svg b/nwg_panel/icons_dark/network-wireless-connected-symbolic.svg deleted file mode 100644 index 0780bd82..00000000 --- a/nwg_panel/icons_dark/network-wireless-connected-symbolic.svg +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/icons_dark/network-wireless-disconnected-symbolic.svg b/nwg_panel/icons_dark/network-wireless-disconnected-symbolic.svg deleted file mode 100644 index 1c056492..00000000 --- a/nwg_panel/icons_dark/network-wireless-disconnected-symbolic.svg +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/icons_light/network-wired-disconnected-symbolic.svg b/nwg_panel/icons_light/network-wired-disconnected-symbolic.svg deleted file mode 100644 index f48377ee..00000000 --- a/nwg_panel/icons_light/network-wired-disconnected-symbolic.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/nwg_panel/icons_light/network-wired-symbolic.svg b/nwg_panel/icons_light/network-wired-symbolic.svg deleted file mode 100644 index 03c758d5..00000000 --- a/nwg_panel/icons_light/network-wired-symbolic.svg +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/nwg_panel/icons_light/network-wireless-connected-symbolic.svg b/nwg_panel/icons_light/network-wireless-connected-symbolic.svg deleted file mode 100644 index a3976e7b..00000000 --- a/nwg_panel/icons_light/network-wireless-connected-symbolic.svg +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/icons_light/network-wireless-disconnected-symbolic.svg b/nwg_panel/icons_light/network-wireless-disconnected-symbolic.svg deleted file mode 100644 index 4546474b..00000000 --- a/nwg_panel/icons_light/network-wireless-disconnected-symbolic.svg +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/nwg_panel/langs/en_US.json b/nwg_panel/langs/en_US.json index e228de0e..7bd59485 100644 --- a/nwg_panel/langs/en_US.json +++ b/nwg_panel/langs/en_US.json @@ -129,8 +129,6 @@ "move-up": "move up", "name": "Name", "name-max-length": "Name max length", - "network-interface": "Network interface", - "network-interface-tooltip": "Network interface status;\nuse `ifconfig` to check names,\ne.g. `enp6s0`or `wlo1`.\nDepends on `python-netifaces`.", "new": "New", "new-file": "New file", "new-panel-config-file-name": "New panel config file name", diff --git a/nwg_panel/langs/pl_PL.json b/nwg_panel/langs/pl_PL.json index a605b04d..9bc6972f 100644 --- a/nwg_panel/langs/pl_PL.json +++ b/nwg_panel/langs/pl_PL.json @@ -129,8 +129,6 @@ "move-up": "przesuń w górę", "name": "Nazwa", "name-max-length": "Maks. długość nazwy", - "network-interface": "Interface sieciowy", - "network-interface-tooltip": "Status interfejsu sieciowego;\nużyj `ifconfig` by sprawdzić nazwę,\nn.p. `enp6s0` lub `wlo1`.\nZależy od pakietu `python-netifaces`.", "new": "Nowy", "new-file": "Nowy plik", "new-panel-config-file-name": "Nazwa nowego pliku konfiguracyjnego panelu", diff --git a/nwg_panel/modules/controls.py b/nwg_panel/modules/controls.py index 41194083..5758b8b9 100644 --- a/nwg_panel/modules/controls.py +++ b/nwg_panel/modules/controls.py @@ -11,7 +11,7 @@ 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, \ - get_interface, update_image, eprint, list_sinks, toggle_mute, create_background_task + update_image, eprint, list_sinks, toggle_mute, create_background_task from nwg_panel.common import commands @@ -35,7 +35,6 @@ def __init__(self, settings, position, alignment, width, monitor=None, icons_pat check_key(settings, "click-closes", False) check_key(settings, "root-css-name", "controls-overview") check_key(settings, "components", ["brightness", "battery", "volume", "processes"]) - check_key(settings, "net-interface", "") check_key(settings, "angle", 0.0) check_key(settings, "battery-low-level", 20) check_key(settings, "battery-low-interval", 3) @@ -45,11 +44,6 @@ def __init__(self, settings, position, alignment, width, monitor=None, icons_pat self.icon_size = settings["icon-size"] - self.net_icon_name = "view-refresh-symbolic" - self.net_image = Gtk.Image.new_from_icon_name(self.net_icon_name, Gtk.IconSize.MENU) - self.net_label = Gtk.Label() if settings["show-values"] else None - self.net_ip_addr = None - self.bri_icon_name = "view-refresh-symbolic" self.bri_image = Gtk.Image.new_from_icon_name(self.bri_icon_name, Gtk.IconSize.MENU) self.bri_label = Gtk.Label() if settings["show-values"] else None @@ -103,14 +97,6 @@ def build_box(self): if self.vol_label: box.pack_start(self.vol_label, False, False, 0) - if "net" in self.settings["components"] and self.settings["net-interface"]: - if commands["netifaces"]: - box.pack_start(self.net_image, False, False, 4) - if self.net_label: - box.pack_start(self.net_label, False, False, 0) - else: - print("'netifaces' python module not found") - if "battery" in self.settings["components"]: box.pack_start(self.bat_image, False, False, 4) if self.bat_label: @@ -119,10 +105,6 @@ def build_box(self): box.pack_start(self.pan_image, False, False, 4) def refresh_output(self): - if "net" in self.settings["components"] and self.settings["net-interface"]: - self.net_ip_addr = get_interface(self.settings["net-interface"]) - GLib.idle_add(self.update_net, self.net_ip_addr) - if "brightness" in self.settings["components"]: try: self.bri_value = get_brightness( @@ -155,15 +137,6 @@ def refresh_bat(self): thread = create_background_task(self.refresh_bat_output, 5) thread.start() - def update_net(self, ip): - icon_name = "network-wired-symbolic" if ip else "network-wired-disconnected-symbolic" - if icon_name != self.net_icon_name: - update_image(self.net_image, icon_name, self.icon_size, self.icons_path) - self.net_icon_name = icon_name - - if self.net_label: - self.net_label.set_text("{}".format(self.settings["net-interface"])) - def update_brightness(self, get=True): icon_name = bri_icon_name(self.bri_value) @@ -272,8 +245,6 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i self.settings = settings self.position = position - self.net_icon_name = "" - self.menu_box = None self.sink_box = None @@ -352,7 +323,7 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.RIGHT, True) GtkLayerShell.set_anchor(self, GtkLayerShell.Edge.BOTTOM, True) - check_key(settings, "commands", {"battery": "", "net": ""}) + check_key(settings, "commands", {"battery": ""}) add_sep = False if "brightness" in settings["components"]: @@ -423,40 +394,6 @@ def __init__(self, parent, position, alignment, settings, width, monitor=None, i sep = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL) v_box.pack_start(sep, True, True, 10) - if "net" in settings["components"] and commands["netifaces"] and settings["net-interface"]: - event_box = Gtk.EventBox() - if "net" in settings["commands"] and settings["commands"]["net"]: - event_box.connect("enter_notify_event", self.on_enter_notify_event) - event_box.connect("leave_notify_event", self.on_leave_notify_event) - - event_box.connect('button-press-event', self.launch, settings["commands"]["net"]) - - inner_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) - inner_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) - inner_vbox.pack_start(inner_hbox, True, True, 6) - v_box.pack_start(event_box, True, True, 0) - - self.net_icon_name = "view-refresh-symbolic" - self.net_image = Gtk.Image.new_from_icon_name(self.net_icon_name, Gtk.IconSize.MENU) - - icon_name = "network-wired-symbolic" if self.parent.net_ip_addr else "network-wired-disconnected-symbolic" - - if icon_name != self.net_icon_name: - update_image(self.net_image, icon_name, self.icon_size, self.icons_path) - self.net_icon_name = icon_name - - inner_hbox.pack_start(self.net_image, False, False, 6) - - self.net_label = Gtk.Label("{}: {}".format(settings["net-interface"], self.parent.net_ip_addr)) - inner_hbox.pack_start(self.net_label, False, True, 6) - - if "net" in settings["commands"] and settings["commands"]["net"]: - img = Gtk.Image() - update_image(img, "pan-end-symbolic", self.icon_size, self.icons_path) - inner_hbox.pack_end(img, False, True, 4) - - event_box.add(inner_vbox) - if "battery" in settings["components"]: event_box = Gtk.EventBox() if "battery" in settings["commands"] and settings["commands"]["battery"]: @@ -646,13 +583,6 @@ def custom_item(self, name, icon, cmd): def refresh(self, *args): if self.get_visible(): self.refresh_sinks() - if "net" in self.settings["components"] and commands["netifaces"] and self.settings["net-interface"]: - if self.parent.net_icon_name != self.net_icon_name: - update_image(self.net_image, self.parent.net_icon_name, self.icon_size, self.icons_path) - self.net_icon_name = self.parent.net_icon_name - - ip_addr = "disconnected" if not self.parent.net_ip_addr else self.parent.net_ip_addr - self.net_label.set_text("{}: {}".format(self.settings["net-interface"], ip_addr)) if "battery" in self.settings["components"]: if self.parent.bat_icon_name != self.bat_icon_name: diff --git a/nwg_panel/tools.py b/nwg_panel/tools.py index 0a7e5ebb..9b397dc3 100644 --- a/nwg_panel/tools.py +++ b/nwg_panel/tools.py @@ -24,11 +24,6 @@ import nwg_panel.common -try: - import netifaces -except ModuleNotFoundError: - pass - try: import psutil except: @@ -391,12 +386,6 @@ def check_commands(): for key in nwg_panel.common.commands: nwg_panel.common.commands[key] = is_command(key) - try: - import netifaces - nwg_panel.common.commands["netifaces"] = True - except ModuleNotFoundError: - pass - try: import requests nwg_panel.common.commands["python-requests"] = True @@ -623,16 +612,6 @@ def seconds2string(seconds): return "{}:{}".format(hrs, minutes) -def get_interface(name): - try: - addrs = netifaces.ifaddresses(name) - list = addrs[netifaces.AF_INET] - - return list[0]["addr"] - except: - return None - - def update_image(image, icon_name, icon_size, icons_path="", fallback=True): scale = image.get_scale_factor() icon_size *= scale