walk_wal.pl 1.1 KB

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