Skip to content

Commit

Permalink
Merge pull request #181 from nwg-piotr/processes
Browse files Browse the repository at this point in the history
Process browser & battery low notification
  • Loading branch information
nwg-piotr authored Feb 19, 2023
2 parents 7fd0fd0 + 9c1ee75 commit 7c4eecf
Show file tree
Hide file tree
Showing 11 changed files with 1,001 additions and 212 deletions.
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
python3 setup.py install --optimize=1
cp nwg-panel.svg /usr/share/pixmaps/
cp nwg-shell.svg /usr/share/pixmaps/
cp nwg-processes.svg /usr/share/pixmaps/
cp nwg-panel-config.desktop /usr/share/applications/
cp nwg-processes.desktop /usr/share/applications/
15 changes: 15 additions & 0 deletions nwg-processes.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Desktop Entry]
Type=Application

Name=nwg-processes

GenericName=nwg-shell process manager
GenericName[pl]=Menadżer zadań nwg-shell

Comment=System process browser
Comment[pl]=Przeglądarka procesów systemowych

Exec=nwg-processes
Icon=nwg-processes
Terminal=false
Categories=System;Utility;
89 changes: 89 additions & 0 deletions nwg-processes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 46 additions & 5 deletions nwg_panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
restart_cmd = "nwg-panel {}".format(args)
print("Restart command: ", restart_cmd)


configs = {}
editor = None
selector_window = None
Expand Down Expand Up @@ -76,6 +75,8 @@
"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"}],
"menu": {"name": "unnamed", "icon": "", "items": []}
},
Expand Down Expand Up @@ -239,6 +240,7 @@ def build_common_settings_window():
global common_settings
check_key(common_settings, "restart-on-display", True)
check_key(common_settings, "restart-delay", 500)
check_key(common_settings, "processes-interval-ms", 2000)

win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
win.set_modal(True)
Expand Down Expand Up @@ -269,11 +271,22 @@ def build_common_settings_window():

sb = Gtk.SpinButton.new_with_range(0, 30000, 100)
sb.set_value(common_settings["restart-delay"])
sb.connect("value-changed", on_restart_delay_changed)
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.")
grid.attach(sb, 1, 1, 1, 1)

lbl = Gtk.Label.new("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.")
grid.attach(sb, 1, 2, 1, 1)

hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
vbox.pack_start(hbox, False, False, 6)

Expand All @@ -292,9 +305,9 @@ def build_common_settings_window():
return win


def on_restart_delay_changed(sb):
def set_int_from_spin_button(sb, config_key):
global common_settings
common_settings["restart-delay"] = int(sb.get_value())
common_settings[config_key] = int(sb.get_value())


def on_restart_check_button(cb):
Expand Down Expand Up @@ -2870,7 +2883,8 @@ def edit_controls(self, *args):
"net",
"brightness",
"volume",
"battery"
"battery",
"processes"
],
"commands": {
},
Expand All @@ -2889,6 +2903,8 @@ def edit_controls(self, *args):
"root-css-name": "controls-overview",
"css-name": "controls-window",
"net-interface": "",
"battery-low-level": 20,
"battery-low-interval": 3,
"angle": 0.0,
"custom-items": [
{
Expand Down Expand Up @@ -2955,6 +2971,21 @@ def edit_controls(self, *args):
self.ctrl_comp_battery = builder.get_object("ctrl-comp-battery")
self.ctrl_comp_battery.set_active("battery" in settings["components"])

self.ctrl_comp_battery_low_level = builder.get_object("ctrl-battery-low-level")
self.ctrl_comp_battery_low_level.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=1, upper=100, step_increment=1, page_increment=10, page_size=1)
self.ctrl_comp_battery_low_level.configure(adj, 1, 0)
self.ctrl_comp_battery_low_level.set_value(settings["battery-low-level"])

self.ctrl_comp_battery_low_interval = builder.get_object("ctrl-battery-low-interval")
self.ctrl_comp_battery_low_interval.set_numeric(True)
adj = Gtk.Adjustment(value=0, lower=0, upper=61, step_increment=1, page_increment=10, page_size=1)
self.ctrl_comp_battery_low_interval.configure(adj, 1, 0)
self.ctrl_comp_battery_low_interval.set_value(settings["battery-low-interval"])

self.ctrl_comp_processes = builder.get_object("ctrl-comp-processes")
self.ctrl_comp_processes.set_active("processes" in settings["components"])

self.ctrl_cdm_net = builder.get_object("ctrl-cmd-net")
check_key(settings["commands"], "net", "")
self.ctrl_cdm_net.set_text(settings["commands"]["net"])
Expand Down Expand Up @@ -3069,13 +3100,23 @@ def update_controls(self):
if "battery" in settings["components"]:
settings["components"].remove("battery")

if self.ctrl_comp_processes.get_active():
if "processes" not in settings["components"]:
settings["components"].append("processes")
else:
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"]["bluetooth"] = self.ctrl_cdm_bluetooth.get_text()
settings["commands"]["battery"] = self.ctrl_cdm_battery.get_text()
settings["root-css-name"] = self.ctrl_root_css_name.get_text()
settings["css-name"] = self.ctrl_css_name.get_text()

settings["battery-low-level"] = int(self.ctrl_comp_battery_low_level.get_value())
settings["battery-low-interval"] = int(self.ctrl_comp_battery_low_interval.get_value())

settings["window-width"] = int(self.ctrl_window_width.get_value())
settings["window-margin-horizontal"] = int(self.ctrl_window_margin_horizontal.get_value())
settings["window-margin-vertical"] = int(self.ctrl_window_margin_vertical.get_value())
Expand Down
Loading

0 comments on commit 7c4eecf

Please sign in to comment.