pwr_tray 1.0.3__tar.gz → 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/PKG-INFO +13 -4
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/README.md +12 -3
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/SwayIdleMgr.py +24 -16
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/main.py +13 -10
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pyproject.toml +1 -1
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/.gitignore +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/LICENSE +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/images/pwr-tray-screenshot.png +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/IniTool.py +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/Utils.py +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/YamlDump.py +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/__init__.py +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/FullSun-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/GoingDown-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/PlayingNow-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/RisingMoon-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetA/pwr-inh-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetA/pwr-no-sleep-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetA/pwr-uninh-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetB/LoBattery-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetB/LockOnlyMode-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetB/NormMode-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetC/New-LockOnly-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetC/New-LowBattery-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetC/New-NormMode-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SetC/New-PresMode-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/SettingSun-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/StopSign-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/Unlocked-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/UnlockedMoon-v03.svg +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/__init__.py +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/pwr_tray/resources/lockpaper.png +0 -0
- {pwr_tray-1.0.3 → pwr_tray-1.0.4}/runner +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pwr_tray
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.4
|
|
4
4
|
Summary: A GTK tray applet for power management for i3/sway/KDE
|
|
5
5
|
Keywords: power,energy,GTK,applet,tray,kde,i3wm,sway
|
|
6
6
|
Author-email: Joe Defen <joedef@google.com>
|
|
@@ -53,8 +53,17 @@ With just a right-click and a left-click, you can do most operations such as cha
|
|
|
53
53
|
* Then, follow the "Per-DE Specific Notes" below to ensure proper operation. To just kick the tires, you can defer this until ready to go forward.
|
|
54
54
|
* Read the other sections for customization and everyday use.
|
|
55
55
|
* From the CLI, you can start/restart pwr-tray in the background with `setsid pwr-tray`; typically, you will "autostart" `pwr-tray` when you log in however your DE/WM manages autostarts.
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
|
|
57
|
+
### Command Line Options
|
|
58
|
+
| Option | Description |
|
|
59
|
+
|--------|-------------|
|
|
60
|
+
| `-o`, `--stdout` | Log to stdout (in addition to the log file); useful for debugging from a terminal. |
|
|
61
|
+
| `-D`, `--debug` | Enable debug mode (more frequent/elaborate logging); overrides the `debug_mode` config setting. |
|
|
62
|
+
| `-q`, `--quick` | Quick mode: sets lock and sleep timeouts to 1 minute and runs double-time (timers expire in 30s wall clock). Useful for testing. |
|
|
63
|
+
| `-e`, `--edit-config` | Open `~/.config/pwr-tray/config.ini` in `$EDITOR` (default: `vim`). |
|
|
64
|
+
| `-f`, `--follow-log` | Tail the log file (`~/.config/pwr-tray/debug.log`). |
|
|
65
|
+
|
|
66
|
+
For initial setup and troubleshooting, `pwr-tray -D -o` is a good starting point.
|
|
58
67
|
|
|
59
68
|
---
|
|
60
69
|
|
|
@@ -167,7 +176,7 @@ bindsym $mod+Escape exec --no-startup-id $screenlock # create shortcut to lock
|
|
|
167
176
|
* In Settings/Energy Saving, disable "Screen Energy Saving", "Suspend session", etc., except keep the "Button events handling" and make it as you wish (e.g., "When power button pressed", "Sleep").
|
|
168
177
|
* In Settings/AutoStart, add the full path of `~/.local/bin/pwr-tray`.
|
|
169
178
|
* `qdbus` (or `qdbus6` on Plasma 6) is required; `pwr-tray` auto-detects which is available.
|
|
170
|
-
* On **KDE Wayland**, idle
|
|
179
|
+
* On **KDE Wayland**, `swayidle` is required (install it if missing). `pwr-tray` manages `swayidle` for idle timeout handling since KDE Wayland does not expose idle time via D-Bus. Locking uses `loginctl lock-session`.
|
|
171
180
|
* On **KDE X11**, idle time is read via `xprintidle` and screen locking uses `loginctl lock-session`.
|
|
172
181
|
|
|
173
182
|
|
|
@@ -35,8 +35,17 @@ With just a right-click and a left-click, you can do most operations such as cha
|
|
|
35
35
|
* Then, follow the "Per-DE Specific Notes" below to ensure proper operation. To just kick the tires, you can defer this until ready to go forward.
|
|
36
36
|
* Read the other sections for customization and everyday use.
|
|
37
37
|
* From the CLI, you can start/restart pwr-tray in the background with `setsid pwr-tray`; typically, you will "autostart" `pwr-tray` when you log in however your DE/WM manages autostarts.
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
|
|
39
|
+
### Command Line Options
|
|
40
|
+
| Option | Description |
|
|
41
|
+
|--------|-------------|
|
|
42
|
+
| `-o`, `--stdout` | Log to stdout (in addition to the log file); useful for debugging from a terminal. |
|
|
43
|
+
| `-D`, `--debug` | Enable debug mode (more frequent/elaborate logging); overrides the `debug_mode` config setting. |
|
|
44
|
+
| `-q`, `--quick` | Quick mode: sets lock and sleep timeouts to 1 minute and runs double-time (timers expire in 30s wall clock). Useful for testing. |
|
|
45
|
+
| `-e`, `--edit-config` | Open `~/.config/pwr-tray/config.ini` in `$EDITOR` (default: `vim`). |
|
|
46
|
+
| `-f`, `--follow-log` | Tail the log file (`~/.config/pwr-tray/debug.log`). |
|
|
47
|
+
|
|
48
|
+
For initial setup and troubleshooting, `pwr-tray -D -o` is a good starting point.
|
|
40
49
|
|
|
41
50
|
---
|
|
42
51
|
|
|
@@ -149,6 +158,6 @@ bindsym $mod+Escape exec --no-startup-id $screenlock # create shortcut to lock
|
|
|
149
158
|
* In Settings/Energy Saving, disable "Screen Energy Saving", "Suspend session", etc., except keep the "Button events handling" and make it as you wish (e.g., "When power button pressed", "Sleep").
|
|
150
159
|
* In Settings/AutoStart, add the full path of `~/.local/bin/pwr-tray`.
|
|
151
160
|
* `qdbus` (or `qdbus6` on Plasma 6) is required; `pwr-tray` auto-detects which is available.
|
|
152
|
-
* On **KDE Wayland**, idle
|
|
161
|
+
* On **KDE Wayland**, `swayidle` is required (install it if missing). `pwr-tray` manages `swayidle` for idle timeout handling since KDE Wayland does not expose idle time via D-Bus. Locking uses `loginctl lock-session`.
|
|
153
162
|
* On **KDE X11**, idle time is read via `xprintidle` and screen locking uses `loginctl lock-session`.
|
|
154
163
|
|
|
@@ -16,28 +16,36 @@ from types import SimpleNamespace
|
|
|
16
16
|
from pwr_tray.Utils import prt
|
|
17
17
|
|
|
18
18
|
class SwayIdleManager:
|
|
19
|
-
""" Class to manage 'swayidle' """
|
|
19
|
+
""" Class to manage 'swayidle' for sway and KDE Wayland """
|
|
20
20
|
def __init__(self, applet):
|
|
21
21
|
self.process = None
|
|
22
22
|
self.applet = applet
|
|
23
23
|
self.current_cmd = ''
|
|
24
24
|
# we construct the sway idle from these clauses which various
|
|
25
25
|
# substitutions.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
if applet.graphical == 'kde-wayland':
|
|
27
|
+
locker = applet.variables.get('locker', 'loginctl lock-session')
|
|
28
|
+
self.clauses = SimpleNamespace(
|
|
29
|
+
leader="""exec swayidle""",
|
|
30
|
+
locker=f""" timeout [lock_s] '{locker}'""",
|
|
31
|
+
blanker="",
|
|
32
|
+
sleeper=""" timeout [sleep_s] 'systemctl suspend'""",
|
|
33
|
+
before_sleep=f""" before-sleep '{locker}'""",
|
|
34
|
+
after_resume="",
|
|
35
|
+
screenlock=locker,
|
|
36
|
+
unblank='',
|
|
37
|
+
)
|
|
38
|
+
else:
|
|
39
|
+
self.clauses = SimpleNamespace(
|
|
40
|
+
leader="""exec swayidle""",
|
|
41
|
+
locker=""" timeout [lock_s] '[screenlock] [lockopts]'""",
|
|
42
|
+
blanker=""" timeout [blank_s] 'swaymsg "output * dpms off"'""",
|
|
43
|
+
sleeper=""" timeout [sleep_s] 'systemctl suspend'""",
|
|
44
|
+
before_sleep=""" before-sleep '[screenlock] [lockopts]'""",
|
|
45
|
+
after_resume=""" after-resume '[unblank]'""",
|
|
46
|
+
screenlock = """pkill swaylock ; exec swaylock --ignore-empty-password --show-failed-attempts""",
|
|
47
|
+
unblank='''; swaymsg "output * dpms on"''',
|
|
48
|
+
)
|
|
41
49
|
self.kill_other_swayidle()
|
|
42
50
|
|
|
43
51
|
@staticmethod
|
|
@@ -137,11 +137,9 @@ class PwrTray:
|
|
|
137
137
|
'restart_wm': 'killall plasmashell && kstart5 plasmashell && sleep 3 && pwr-tray',
|
|
138
138
|
'must_haves': 'loginctl qdbus'.split(),
|
|
139
139
|
}, 'kde-wayland': {
|
|
140
|
-
'get_idle_s': 'qdbus org.freedesktop.ScreenSaver /ScreenSaver GetSessionIdleTime',
|
|
141
|
-
'reset_idle': 'qdbus org.freedesktop.ScreenSaver /ScreenSaver SimulateUserActivity',
|
|
142
140
|
'locker': 'loginctl lock-session',
|
|
143
141
|
'logoff': 'qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 0 0',
|
|
144
|
-
'must_haves': 'loginctl'.split(),
|
|
142
|
+
'must_haves': 'loginctl swayidle'.split(),
|
|
145
143
|
}, 'gnome-x11': {
|
|
146
144
|
|
|
147
145
|
}, 'gnome-wayland': {
|
|
@@ -255,7 +253,8 @@ class PwrTray:
|
|
|
255
253
|
self.has_playerctl = bool(shutil.which('playerctl'))
|
|
256
254
|
|
|
257
255
|
|
|
258
|
-
self.idle_manager = SwayIdleManager(self)
|
|
256
|
+
self.idle_manager = (SwayIdleManager(self)
|
|
257
|
+
if self.graphical in ('sway', 'kde-wayland') else None)
|
|
259
258
|
|
|
260
259
|
self.menu_items = []
|
|
261
260
|
self.menu = None
|
|
@@ -362,10 +361,13 @@ class PwrTray:
|
|
|
362
361
|
cmd = self.variables.get('get_idle_s', '')
|
|
363
362
|
scale = 1000
|
|
364
363
|
if cmd:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
364
|
+
try:
|
|
365
|
+
xidle = int(subprocess.check_output(cmd.split()).strip())
|
|
366
|
+
xidle_ms = xidle * scale
|
|
367
|
+
xidle_ms *= 2 if self.quick else 1 # time warp
|
|
368
|
+
self.running_idle_s = round(xidle_ms/1000, 3)
|
|
369
|
+
except Exception as e:
|
|
370
|
+
prt(f'WARN: idle time command failed: {e}')
|
|
369
371
|
|
|
370
372
|
def DB(self):
|
|
371
373
|
""" is debug on? """
|
|
@@ -535,8 +537,8 @@ class PwrTray:
|
|
|
535
537
|
prt(emit)
|
|
536
538
|
|
|
537
539
|
if emode in ('Presentation',) or self.was_inhibited:
|
|
538
|
-
if
|
|
539
|
-
self.reset_xidle_ms() #
|
|
540
|
+
if self.idle_manager:
|
|
541
|
+
self.reset_xidle_ms() # idle_manager handles timeouts
|
|
540
542
|
elif self.running_idle_s > min(50, lock_secs*0.40):
|
|
541
543
|
self.reset_xidle_ms() # we don't know when
|
|
542
544
|
|
|
@@ -980,6 +982,7 @@ def main():
|
|
|
980
982
|
atexit.register(PwrTray.goodbye)
|
|
981
983
|
|
|
982
984
|
|
|
985
|
+
ini_tool.update_config()
|
|
983
986
|
if opts.debug:
|
|
984
987
|
for selector in ini_tool.get_selectors():
|
|
985
988
|
ini_tool.params_by_selector[selector].debug_mode = True # one-time override
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|