-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrp-groups-menu
executable file
·44 lines (36 loc) · 1.02 KB
/
rp-groups-menu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
# vim: ft=perl nolist:
# abstract: ratpoison groups menu
use strict;
my $type = 'groups';
my $select = 'select';
if ($ARGV[0] and $ARGV[0] eq '-g') {
$type = 'groups';
$select = 'gselect';
}
my @windowlist = split(/\n/, `ratpoison -c $type`);
# Check if there are any groups, if not simulate ratpoison's
# behaviour
if ($#windowlist == 0 and $windowlist[0] !~ /^\d/) {
exec('ratpoison', '-c', "echo No managed $type");
# Else create a group list sorted and suitable for ratmenu
} else {
my %windowlist = map { /^(\d+)/ => $_ } @windowlist;
@windowlist = map { $windowlist{$_} => "ratpoison -c '$select $_'" }
sort { $a <=> $b }
keys %windowlist;
# Search group which would be next by default
my $io = 0;
my $found = 0;
for my $i (@windowlist) {
$io++ if $i =~ /^\d/;
if ($i =~ /^\d+\+/) {
$found = 1;
last;
}
}
$io = 1 unless $found;
system 'ratmenu',
qw(-style dreary), qw(-fg black -bg orange),
'-label', 'ratmenu: ratpoison groups', '-io', $io, @windowlist;
}