|
33 | 33 | min_seconds = 0 |
34 | 34 | seconds_passed = 0 |
35 | 35 | tray_icon_path = None |
| 36 | +icon_lock_later_path = None |
36 | 37 |
|
37 | 38 |
|
38 | 39 | def __lock_screen_command(): |
@@ -102,21 +103,29 @@ def __lock_screen_command(): |
102 | 103 | return None |
103 | 104 |
|
104 | 105 |
|
105 | | -def __lock_screen(): |
| 106 | +def __lock_screen_later(): |
106 | 107 | global user_locked_screen |
107 | 108 | user_locked_screen = True |
108 | 109 |
|
109 | 110 |
|
| 111 | +def __lock_screen_now() -> None: |
| 112 | + utility.execute_command(lock_screen_command) |
| 113 | + |
| 114 | + |
110 | 115 | def init(ctx, safeeyes_config, plugin_config): |
111 | 116 | """Initialize the screensaver plugin.""" |
112 | 117 | global context |
113 | 118 | global lock_screen_command |
114 | 119 | global min_seconds |
115 | 120 | global tray_icon_path |
| 121 | + global icon_lock_later_path |
116 | 122 | logging.debug("Initialize Screensaver plugin") |
117 | 123 | context = ctx |
118 | 124 | min_seconds = plugin_config["min_seconds"] |
119 | 125 | tray_icon_path = os.path.join(plugin_config["path"], "resource/lock.png") |
| 126 | + icon_lock_later_path = os.path.join( |
| 127 | + plugin_config["path"], "resource/rotation-lock-symbolic.svg" |
| 128 | + ) |
120 | 129 | if plugin_config["command"]: |
121 | 130 | lock_screen_command = plugin_config["command"].split() |
122 | 131 | else: |
@@ -147,10 +156,22 @@ def on_stop_break(): |
147 | 156 | min_seconds. |
148 | 157 | """ |
149 | 158 | if user_locked_screen or (lock_screen and seconds_passed >= min_seconds): |
150 | | - utility.execute_command(lock_screen_command) |
151 | | - |
152 | | - |
153 | | -def get_tray_action(break_obj): |
154 | | - return TrayAction.build( |
155 | | - "Lock screen", tray_icon_path, "dialog-password", __lock_screen |
156 | | - ) |
| 159 | + __lock_screen_now() |
| 160 | + |
| 161 | + |
| 162 | +def get_tray_action(break_obj) -> list[TrayAction]: |
| 163 | + return [ |
| 164 | + TrayAction.build( |
| 165 | + "Lock screen now", |
| 166 | + tray_icon_path, |
| 167 | + "system-lock-screen", |
| 168 | + __lock_screen_now, |
| 169 | + single_use=False, |
| 170 | + ), |
| 171 | + TrayAction.build( |
| 172 | + "Lock screen after break", |
| 173 | + icon_lock_later_path, |
| 174 | + "dialog-password", |
| 175 | + __lock_screen_later, |
| 176 | + ), |
| 177 | + ] |
0 commit comments