From: Mark Wooding Date: Sat, 30 May 2020 15:14:11 +0000 (+0100) Subject: bin/disorder-notify: New operation to cycle through configurations. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/commitdiff_plain/70291d8de55c7625327e1bac438ab588ed26e158 bin/disorder-notify: New operation to cycle through configurations. --- diff --git a/bin/disorder-notify b/bin/disorder-notify index e67668f..d26a565 100755 --- a/bin/disorder-notify +++ b/bin/disorder-notify @@ -283,6 +283,31 @@ $OP{"notify-now-playing"} = sub { defined locked_by or watch_and_notify 0; }; +$OP{"next-config"} = sub { + (my $dir = $C{config}) =~ s:/[^/]*$::; + my (@conf, $curr, $conf, $min); + + if (-l $C{config} && (my $t = readlink $C{config}) =~ /^passwd\.(.*)$/) + { $curr = $1; } + + opendir my $dh, +$dir; + FILE: while (my $f = readdir $dh) + { push @conf, $1 if $f =~ /^passwd\.(.*[^~])$/; } + + for (my $i = 0; $i < @conf; $i++) { + $min = $conf[$i] if (!defined $min) || $conf[$i] lt $min; + $conf = $conf[$i] + if ((!defined $curr) || $curr lt $conf[$i]) && + ((!defined $conf) || $conf[$i] lt $conf); + } + $conf = $min unless defined $conf; + + try_unlink "$dir/passwd.new"; + symlink "passwd.$conf", "$dir/passwd.new"; + rename "$dir/passwd.new", "$dir/passwd"; + notify "DisOrder configuration", "Switched to `$conf'"; +}; + ###-------------------------------------------------------------------------- ### Main program. diff --git a/dot/e16-bindings b/dot/e16-bindings index c1ae372..d6c547f 100644 --- a/dot/e16-bindings +++ b/dot/e16-bindings @@ -59,6 +59,7 @@ KeyDown C5 w menus show winops.menu KeyDown C5 x wop * close KeyDown C5 numbersign exec xinitcmd pavucontrol KeyDown C5 apostrophe exec xinitcmd disobedience +KeyDown C5 semicolon exec disorder-notify next-config KeyDown C5 plus exec disorder-notify volume-up KeyDown C5 minus exec disorder-notify volume-down KeyDown C5 period exec disorder-notify enable/disable