1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4
5 # Stupid script to interactively walk through all wal themes, and save
6 # a bunch of aliases of themes you like
7
8 # wal --theme | grep " - " | grep -v random | sed s/^\ -\ //g
9 my $wal_path = "/home/swatson/.local/bin/wal";
10 my $theme_cmd = "$wal_path -n -e --theme";
11 my @saved;
12 my @avail_themes = split("\n", `$wal_path --theme | grep " - " | grep -v random | sed s/^\\ -\\ //g`);
13
14
15
16 sub set_wal($) {
17
18 my $theme = shift;
19 system("$theme_cmd $theme");
20
21 }
22
23 sub gen_alias($) {
24
25 my $theme = shift;
26 my $alias = "alias wal-$theme='wal -n -e --theme $theme'";
27 return $alias;
28
29 }
30
31 sub dump_saved() {
32
33 foreach my $entry ( @saved ) {
34 print "$entry\n";
35 }
36
37 }
38
39 foreach my $theme ( @avail_themes ) {
40
41 set_wal($theme);
42 print "Theme is: $theme\n";
43 print "Hit n for next, a to add to alias list, q to quit\n";
44 my $input = <STDIN>;
45 chomp $input;
46
47 if ( $input =~ m/n/ ) {
48 next;
49 } elsif ( $input =~ m/a/ ) {
50 my $alias = gen_alias($theme);
51 push(@saved,$alias);
52 print "Saved $theme\n";
53 next;
54 } elsif ( $input =~ m/q/ ) {
55 dump_saved();
56 exit 0;
57 } else {
58 next;
59 }
60
61 }
62
63 dump_saved();