add battery low notification #180
This commit is contained in:
@@ -39,7 +39,6 @@ args = load_string(args_file) if os.path.isfile(args_file) else ""
|
|||||||
restart_cmd = "nwg-panel {}".format(args)
|
restart_cmd = "nwg-panel {}".format(args)
|
||||||
print("Restart command: ", restart_cmd)
|
print("Restart command: ", restart_cmd)
|
||||||
|
|
||||||
|
|
||||||
configs = {}
|
configs = {}
|
||||||
editor = None
|
editor = None
|
||||||
selector_window = None
|
selector_window = None
|
||||||
@@ -76,6 +75,8 @@ SKELETON_PANEL: dict = {
|
|||||||
"root-css-name": "controls-overview",
|
"root-css-name": "controls-overview",
|
||||||
"css-name": "controls-window",
|
"css-name": "controls-window",
|
||||||
"net-interface": "",
|
"net-interface": "",
|
||||||
|
"battery-low-level": 20,
|
||||||
|
"battery-low-interval": 3,
|
||||||
"custom-items": [{"name": "Panel settings", "icon": "nwg-panel", "cmd": "nwg-panel-config"}],
|
"custom-items": [{"name": "Panel settings", "icon": "nwg-panel", "cmd": "nwg-panel-config"}],
|
||||||
"menu": {"name": "unnamed", "icon": "", "items": []}
|
"menu": {"name": "unnamed", "icon": "", "items": []}
|
||||||
},
|
},
|
||||||
@@ -2902,6 +2903,8 @@ class EditorWrapper(object):
|
|||||||
"root-css-name": "controls-overview",
|
"root-css-name": "controls-overview",
|
||||||
"css-name": "controls-window",
|
"css-name": "controls-window",
|
||||||
"net-interface": "",
|
"net-interface": "",
|
||||||
|
"battery-low-level": 20,
|
||||||
|
"battery-low-interval": 3,
|
||||||
"angle": 0.0,
|
"angle": 0.0,
|
||||||
"custom-items": [
|
"custom-items": [
|
||||||
{
|
{
|
||||||
@@ -2968,6 +2971,18 @@ class EditorWrapper(object):
|
|||||||
self.ctrl_comp_battery = builder.get_object("ctrl-comp-battery")
|
self.ctrl_comp_battery = builder.get_object("ctrl-comp-battery")
|
||||||
self.ctrl_comp_battery.set_active("battery" in settings["components"])
|
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 = builder.get_object("ctrl-comp-processes")
|
||||||
self.ctrl_comp_processes.set_active("processes" in settings["components"])
|
self.ctrl_comp_processes.set_active("processes" in settings["components"])
|
||||||
|
|
||||||
@@ -3099,6 +3114,9 @@ class EditorWrapper(object):
|
|||||||
settings["root-css-name"] = self.ctrl_root_css_name.get_text()
|
settings["root-css-name"] = self.ctrl_root_css_name.get_text()
|
||||||
settings["css-name"] = self.ctrl_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-width"] = int(self.ctrl_window_width.get_value())
|
||||||
settings["window-margin-horizontal"] = int(self.ctrl_window_margin_horizontal.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())
|
settings["window-margin-vertical"] = int(self.ctrl_window_margin_vertical.get_value())
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
<property name="label-xalign">0.5</property>
|
<property name="label-xalign">0.5</property>
|
||||||
<property name="shadow-type">out</property>
|
<property name="shadow-type">out</property>
|
||||||
<child>
|
<child>
|
||||||
<!-- n-columns=5 n-rows=16 -->
|
<!-- n-columns=5 n-rows=18 -->
|
||||||
<object class="GtkGrid" id="grid">
|
<object class="GtkGrid" id="grid">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
@@ -18,278 +18,6 @@
|
|||||||
<property name="margin-bottom">6</property>
|
<property name="margin-bottom">6</property>
|
||||||
<property name="row-spacing">12</property>
|
<property name="row-spacing">12</property>
|
||||||
<property name="column-spacing">12</property>
|
<property name="column-spacing">12</property>
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="css-name">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="width-chars">12</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">7</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">CSS name:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">7</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkEntry" id="root-css-name">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="width-chars">12</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">6</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Root CSS name:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">6</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Window width:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">8</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkImage">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Controls window width in pixels; leave 0 for auto.</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="icon-name">help-about</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">3</property>
|
|
||||||
<property name="top-attach">8</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="window-width">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">8</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="interval">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">12</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Interval:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">12</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="icon-size">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">11</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Icon size:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">11</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Horizontal window margin:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">9</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="window-margin-horizontal">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">9</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBoxText" id="angle">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">the angle that the baseline of the label makes with
|
|
||||||
the horizontal, in degrees, measured counterclockwise</property>
|
|
||||||
<items>
|
|
||||||
<item id="0.0" translatable="yes">0°</item>
|
|
||||||
<item id="90.0" translatable="yes">90°</item>
|
|
||||||
<item id="270.0" translatable="yes">270°</item>
|
|
||||||
</items>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">13</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Angle:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">13</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="halign">end</property>
|
|
||||||
<property name="label" translatable="yes">Vertical window margin:</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">10</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkSpinButton" id="window-margin-vertical">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">2</property>
|
|
||||||
<property name="top-attach">10</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="hover-opens">
|
|
||||||
<property name="label" translatable="yes">Widget hover opens</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">False</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Determines if to open the Controls window
|
|
||||||
on panel Controls widget pointed</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="leave-closes">
|
|
||||||
<property name="label" translatable="yes">Window leave closes</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">False</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
|
|
||||||
window when left</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="click-closes">
|
|
||||||
<property name="label" translatable="yes">Click outside closes</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">False</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
|
|
||||||
window on mouse click outside it</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">15</property>
|
|
||||||
<property name="width">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="show-values">
|
|
||||||
<property name="label" translatable="yes">Values in widget</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">False</property>
|
|
||||||
<property name="tooltip-text" translatable="yes">Determines if show the Controls
|
|
||||||
values in the panel widget</property>
|
|
||||||
<property name="draw-indicator">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left-attach">0</property>
|
|
||||||
<property name="top-attach">14</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="ctrl-comp-brightness">
|
<object class="GtkCheckButton" id="ctrl-comp-brightness">
|
||||||
<property name="label" translatable="yes">Brightness</property>
|
<property name="label" translatable="yes">Brightness</property>
|
||||||
@@ -532,6 +260,300 @@ Depends on `python-netifaces`.</property>
|
|||||||
<property name="top-attach">4</property>
|
<property name="top-attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Battery low notification at [%]:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="ctrl-battery-low-level">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="hover-opens">
|
||||||
|
<property name="label" translatable="yes">Widget hover opens</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Determines if to open the Controls window
|
||||||
|
on panel Controls widget pointed</property>
|
||||||
|
<property name="draw-indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="leave-closes">
|
||||||
|
<property name="label" translatable="yes">Window leave closes</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
|
||||||
|
window when left</property>
|
||||||
|
<property name="draw-indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="click-closes">
|
||||||
|
<property name="label" translatable="yes">Click outside closes</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Determines if to close the Controls
|
||||||
|
window on mouse click outside it</property>
|
||||||
|
<property name="draw-indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">17</property>
|
||||||
|
<property name="width">5</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="show-values">
|
||||||
|
<property name="label" translatable="yes">Values in widget</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Determines if show the Controls
|
||||||
|
values in the panel widget</property>
|
||||||
|
<property name="draw-indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">16</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Angle:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">15</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="angle">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">the angle that the baseline of the label makes with
|
||||||
|
the horizontal, in degrees, measured counterclockwise</property>
|
||||||
|
<items>
|
||||||
|
<item id="0.0" translatable="yes">0°</item>
|
||||||
|
<item id="90.0" translatable="yes">90°</item>
|
||||||
|
<item id="270.0" translatable="yes">270°</item>
|
||||||
|
</items>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">15</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Interval:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">14</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="interval">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">14</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Icon size:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">13</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="icon-size">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">13</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Vertical window margin:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">12</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="window-margin-vertical">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">12</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Horizontal window margin:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">11</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="window-margin-horizontal">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">11</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Window width:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">10</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="window-width">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">10</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">CSS name:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">9</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="css-name">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="width-chars">12</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">9</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">Root CSS name:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">8</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="root-css-name">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="width-chars">12</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">8</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Controls window width in pixels; leave 0 for auto.</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="icon-name">help-about</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">3</property>
|
||||||
|
<property name="top-attach">10</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkCheckButton" id="ctrl-comp-processes">
|
<object class="GtkCheckButton" id="ctrl-comp-processes">
|
||||||
<property name="label" translatable="yes">Processes</property>
|
<property name="label" translatable="yes">Processes</property>
|
||||||
@@ -543,7 +565,7 @@ Depends on `python-netifaces`.</property>
|
|||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">0</property>
|
<property name="left-attach">0</property>
|
||||||
<property name="top-attach">5</property>
|
<property name="top-attach">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -556,9 +578,58 @@ Depends on `python-netifaces`.</property>
|
|||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left-attach">1</property>
|
<property name="left-attach">1</property>
|
||||||
<property name="top-attach">5</property>
|
<property name="top-attach">7</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="label" translatable="yes">Low level check interval [min]</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">6</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSpinButton" id="ctrl-battery-low-interval">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">6</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Set 0 to disable.</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="icon-name">help-about</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">3</property>
|
||||||
|
<property name="top-attach">6</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
@@ -15,6 +16,8 @@ from nwg_panel.tools import check_key, get_brightness, set_brightness, get_volum
|
|||||||
|
|
||||||
from nwg_panel.common import commands
|
from nwg_panel.common import commands
|
||||||
|
|
||||||
|
bat_critical_last_check = 0
|
||||||
|
|
||||||
|
|
||||||
class Controls(Gtk.EventBox):
|
class Controls(Gtk.EventBox):
|
||||||
def __init__(self, settings, position, alignment, width, monitor=None, icons_path=""):
|
def __init__(self, settings, position, alignment, width, monitor=None, icons_path=""):
|
||||||
@@ -32,9 +35,11 @@ class Controls(Gtk.EventBox):
|
|||||||
check_key(settings, "leave-closes", True)
|
check_key(settings, "leave-closes", True)
|
||||||
check_key(settings, "click-closes", False)
|
check_key(settings, "click-closes", False)
|
||||||
check_key(settings, "root-css-name", "controls-overview")
|
check_key(settings, "root-css-name", "controls-overview")
|
||||||
check_key(settings, "components", ["net", "brightness", "volume", "battery"])
|
check_key(settings, "components", ["brightness", "battery", "volume", "processes"])
|
||||||
check_key(settings, "net-interface", "")
|
check_key(settings, "net-interface", "")
|
||||||
check_key(settings, "angle", 0.0)
|
check_key(settings, "angle", 0.0)
|
||||||
|
check_key(settings, "battery-low-level", 20)
|
||||||
|
check_key(settings, "battery-low-interval", 3)
|
||||||
|
|
||||||
self.set_property("name", settings["root-css-name"])
|
self.set_property("name", settings["root-css-name"])
|
||||||
|
|
||||||
@@ -235,6 +240,14 @@ class Controls(Gtk.EventBox):
|
|||||||
if self.bat_label:
|
if self.bat_label:
|
||||||
self.bat_label.set_text("{}%".format(value))
|
self.bat_label.set_text("{}%".format(value))
|
||||||
|
|
||||||
|
if self.settings["battery-low-interval"] > 0:
|
||||||
|
t = int(time.time())
|
||||||
|
global bat_critical_last_check
|
||||||
|
if not charging and t - bat_critical_last_check >= self.settings["battery-low-interval"] * 60 and value <= \
|
||||||
|
self.settings["battery-low-level"]:
|
||||||
|
subprocess.Popen('notify-send "Battery low!" -i {}'.format(icon_name), shell=True)
|
||||||
|
bat_critical_last_check = t
|
||||||
|
|
||||||
def on_button_press(self, w, event, settings):
|
def on_button_press(self, w, event, settings):
|
||||||
if not self.popup_window.get_visible():
|
if not self.popup_window.get_visible():
|
||||||
self.popup_window.show_all()
|
self.popup_window.show_all()
|
||||||
|
Reference in New Issue
Block a user