@@ -3,6 +3,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
3
3
int image_size;
4
4
bool autohide;
5
5
string [] blacklist;
6
+ bool loop;
6
7
}
7
8
8
9
public class Mpris : BaseWidget {
@@ -29,6 +30,7 @@ namespace SwayNotificationCenter.Widgets.Mpris {
29
30
Config mpris_config = Config () {
30
31
image_size = 96 ,
31
32
autohide = false ,
33
+ loop = false ,
32
34
};
33
35
34
36
public Mpris (string suffix , SwayncDaemon swaync_daemon , NotiDaemon noti_daemon ) {
@@ -63,8 +65,8 @@ namespace SwayNotificationCenter.Widgets.Mpris {
63
65
button_next. sensitive = false ;
64
66
return ;
65
67
}
66
- button_prev. sensitive = index > 0 ;
67
- button_next. sensitive = index < carousel. n_pages - 1 ;
68
+ button_prev. sensitive = ( index > 0 ) || mpris_config . loop ;
69
+ button_next. sensitive = ( index < carousel. n_pages - 1 ) || mpris_config . loop ;
68
70
});
69
71
70
72
carousel_box. append (button_prev);
@@ -100,6 +102,11 @@ namespace SwayNotificationCenter.Widgets.Mpris {
100
102
bool autohide_found;
101
103
bool ? autohide = get_prop< bool > (config, " autohide" , out autohide_found);
102
104
if (autohide_found) mpris_config. autohide = autohide;
105
+
106
+ // Get loop
107
+ bool loop_found;
108
+ bool ? loop = get_prop< bool > (config, " loop" , out loop_found);
109
+ if (loop_found) mpris_config. loop = loop;
103
110
}
104
111
105
112
hide ();
@@ -225,8 +232,13 @@ namespace SwayNotificationCenter.Widgets.Mpris {
225
232
private void change_carousel_position (int delta ) {
226
233
uint children_length = carousel. n_pages;
227
234
if (children_length == 0 ) return ;
228
- uint position = ((uint ) carousel. position + delta)
229
- .clamp (0 , (children_length - 1 ));
235
+ uint position;
236
+ if (mpris_config. loop) {
237
+ position = ((uint ) carousel. position + delta) % children_length;
238
+ } else {
239
+ position = ((uint ) carousel. position + delta)
240
+ .clamp (0 , (children_length - 1 ));
241
+ }
230
242
carousel. scroll_to (carousel. get_nth_page (position), true );
231
243
}
232
244
0 commit comments