@@ -39,6 +39,7 @@ class Extension(CastBoolMixin, Plugin):
39
39
40
40
next_background_event = asyncio .Event ()
41
41
cur_image = ""
42
+ _paused = False
42
43
43
44
async def on_reload (self ) -> None :
44
45
"""Re-build the image list."""
@@ -88,34 +89,35 @@ async def main_loop(self) -> None:
88
89
variables = state .variables .copy ()
89
90
90
91
while self .running :
91
- self .next_background_event .clear ()
92
-
93
- # Define the command template based on the 'unique' flag
94
- cmd_template = self .config .get (
95
- "command" ,
96
- ('swaybg -o [output] -m fill -i "[file]"' if unique else 'swaybg -m fill -i "[file]"' ),
97
- )
98
-
99
- if unique :
100
- monitors = await self .hyprctl_json ("monitors" )
101
- old_filename = None
102
- for monitor in monitors :
103
- filename = prepare_for_quotes (self .select_next_image ())
104
- while filename == old_filename :
92
+ if not self ._paused :
93
+ self .next_background_event .clear ()
94
+
95
+ # Define the command template based on the 'unique' flag
96
+ cmd_template = self .config .get (
97
+ "command" ,
98
+ ('swaybg -o [output] -m fill -i "[file]"' if unique else 'swaybg -m fill -i "[file]"' ),
99
+ )
100
+
101
+ if unique :
102
+ monitors = await self .hyprctl_json ("monitors" )
103
+ old_filename = None
104
+ for monitor in monitors :
105
105
filename = prepare_for_quotes (self .select_next_image ())
106
- variables .update ({"file" : filename , "output" : monitor ["name" ]})
106
+ while filename == old_filename :
107
+ filename = prepare_for_quotes (self .select_next_image ())
108
+ variables .update ({"file" : filename , "output" : monitor ["name" ]})
109
+ await self ._run_one (cmd_template , variables )
110
+ else :
111
+ filename = self .select_next_image ().replace ('"' , '\\ "' )
112
+ variables .update ({"file" : filename })
107
113
await self ._run_one (cmd_template , variables )
108
- else :
109
- filename = self .select_next_image ().replace ('"' , '\\ "' )
110
- variables .update ({"file" : filename })
111
- await self ._run_one (cmd_template , variables )
112
114
113
- await asyncio .sleep (1 ) # wait for the command(s) to start
115
+ await asyncio .sleep (1 ) # wait for the command(s) to start
114
116
115
- # check if the command failed
116
- for proc in self .proc :
117
- if proc .returncode :
118
- await self .notify_error ("wallpaper command failed" )
117
+ # check if the command failed
118
+ for proc in self .proc :
119
+ if proc .returncode :
120
+ await self .notify_error ("wallpaper command failed" )
119
121
120
122
interval = asyncio .sleep (60 * self .config .get ("interval" , 10 ) - 1 )
121
123
await asyncio .wait (
@@ -140,6 +142,7 @@ async def terminate(self) -> None:
140
142
async def run_wall (self , arg : str ) -> None :
141
143
"""<next|clear> skip the current background image or stop displaying it."""
142
144
if arg .startswith ("n" ):
145
+ self ._paused = False
143
146
self .next_background_event .set ()
144
147
elif arg .startswith ("c" ):
145
148
clear_command = self .config .get ("clear_command" )
@@ -149,4 +152,5 @@ async def run_wall(self, arg: str) -> None:
149
152
# wait for it to finish
150
153
await proc .wait ()
151
154
else :
155
+ self ._paused = True
152
156
await self .terminate ()
0 commit comments