pwr_tray 1.0.3__py3-none-any.whl → 1.0.4__py3-none-any.whl

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/SwayIdleMgr.py CHANGED
@@ -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
- self.clauses = SimpleNamespace(
27
- leader="""exec swayidle""",
28
- locker=""" timeout [lock_s] '[screenlock] [lockopts]'""",
29
- blanker=""" timeout [blank_s] 'swaymsg "output * dpms off"'""",
30
- sleeper=""" timeout [sleep_s] 'systemctl suspend'""",
31
- # dimmer="""\\\n timeout [dim_s] 'brightnessctl set 50%'""", # perms?
32
- before_sleep=""" before-sleep '[screenlock] [lockopts]'""",
33
- after_resume=""" after-resume '[unblank]'""",
34
- # + """ 'pgrep -x copyq || copyq --start-server hide;"""
35
- # + """ pgrep -x nm-applet || nm-applet [undim][dpmsOn]'""",
36
- # + """ pgrep -x nm-applet || nm-applet [unblank]'""",
37
- # undim = """; brightnessctl set 100%""",
38
- screenlock = """pkill swaylock ; exec swaylock --ignore-empty-password --show-failed-attempts""",
39
- unblank='''; swaymsg "output * dpms on"''',
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
pwr_tray/main.py CHANGED
@@ -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) if self.graphical == 'sway' else None
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
- 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)
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 'sway' in self.graphical:
539
- self.reset_xidle_ms() # we don't know when
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pwr_tray
3
- Version: 1.0.3
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
- * `pwr-tray -e` edits the config file (`~/.config/pwr-tray/config.ini`)
57
- * `pwr-tray -f` tails the log file (`~/.config/pwr-tray/debug.log`)
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 time is read via D-Bus (`org.freedesktop.ScreenSaver`). Locking uses `loginctl lock-session`.
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
 
@@ -1,9 +1,9 @@
1
1
  pwr_tray/IniTool.py,sha256=tpqu-B0K4EYmcS5J_WvDwFtHufH2639b6iPCo0Nnz6I,7339
2
- pwr_tray/SwayIdleMgr.py,sha256=ElaJ2aoxFYZXjWZ8tlQEjGNL-CUpgUsmtAknyC3mFsQ,5667
2
+ pwr_tray/SwayIdleMgr.py,sha256=xMQPcoUdXd9jT0aFFlsSkpImkO9V0i9GFkJ_xEaefDU,5906
3
3
  pwr_tray/Utils.py,sha256=mG1V_Ulpu6pAp6TQT1MzSpvCkpYknq5xVW2gv5cslEw,5676
4
4
  pwr_tray/YamlDump.py,sha256=dwr9_mBhdaj2zqI_292xzflmpITrPlN4SB2SfmXOulQ,5854
5
5
  pwr_tray/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pwr_tray/main.py,sha256=A909KOrppI-bD7JYkbQZqCiL6U613auv2f6qnCPurO0,38445
6
+ pwr_tray/main.py,sha256=P4zSCZamdmS4_-Eu_J25NThe6EV8nT_ZNxTKHmEFdd8,38454
7
7
  pwr_tray/resources/FullSun-v03.svg,sha256=b9oNpRluyfIMmVhizVq-JhsLGJQBd41PTk6l6Yj3LmU,2256
8
8
  pwr_tray/resources/GoingDown-v03.svg,sha256=7qGoWz49_xFhcsWmdIC-wpT_hNrva5rGXiwdFNgE5m0,2321
9
9
  pwr_tray/resources/PlayingNow-v03.svg,sha256=6dTRn4b5NQhXmMn49oIeXkBdFE1NiCR4Am4wvgXNOmw,2189
@@ -24,8 +24,8 @@ pwr_tray/resources/SetC/New-LockOnly-v03.svg,sha256=HpnOIl175DCIrg2pGJSn9YLbRR5d
24
24
  pwr_tray/resources/SetC/New-LowBattery-v03.svg,sha256=72Tm4yU1_-YGVTdLaYtJBNKwcl173974BcDRk8OQ01Y,1143
25
25
  pwr_tray/resources/SetC/New-NormMode-v03.svg,sha256=UxEBP7srvA7DFgpajvvQhtQbxfotME5wTITlY1-Q74g,1143
26
26
  pwr_tray/resources/SetC/New-PresMode-v03.svg,sha256=X1fP8mzXyWvvPe2Jxa5W8q9IluyOQZC1KgO8gD752zc,1362
27
- pwr_tray-1.0.3.dist-info/entry_points.txt,sha256=8Fq3iMpHn6B3SE-wbiIHAb2JJrJQoRNqxn02ou90pNg,47
28
- pwr_tray-1.0.3.dist-info/licenses/LICENSE,sha256=4OhhqMihLcd6MSTlS7OLjKy8D6sjATCTU7ds4K2YXe0,1062
29
- pwr_tray-1.0.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
30
- pwr_tray-1.0.3.dist-info/METADATA,sha256=sS7AWSJds3Ibd_Jt3D_L_m-FH6QCQ33sK3hunJxIKNo,11550
31
- pwr_tray-1.0.3.dist-info/RECORD,,
27
+ pwr_tray-1.0.4.dist-info/entry_points.txt,sha256=8Fq3iMpHn6B3SE-wbiIHAb2JJrJQoRNqxn02ou90pNg,47
28
+ pwr_tray-1.0.4.dist-info/licenses/LICENSE,sha256=4OhhqMihLcd6MSTlS7OLjKy8D6sjATCTU7ds4K2YXe0,1062
29
+ pwr_tray-1.0.4.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
30
+ pwr_tray-1.0.4.dist-info/METADATA,sha256=1ftCWUKip9xNbrLvcOCfhB1LY_-SDd6uNtL_SxDyn5g,12217
31
+ pwr_tray-1.0.4.dist-info/RECORD,,