From 6d33d9446f36f87b759529ff719c22801c92dadc Mon Sep 17 00:00:00 2001 From: John Mertz Date: Fri, 6 Jan 2023 14:41:31 -0500 Subject: [PATCH] tabs->spaces --- audio/stream-podcasts.pl | 58 +- distrobox/debian12/gammastep.pl | 50 +- distrobox/invalid-terminal.sh | 4 +- i3/i3move.sh | 24 +- rofi/drun.sh | 4 +- rofi/rofi-openvpn.sh | 28 +- rofi/rofi-send-to-kodi.sh | 4 +- rofi/rofi-ssh-menu.sh | 28 +- rofi/rofi-sway-rotate.sh | 10 +- rofi/rofi-yubioath.sh | 8 +- rofi/sway-alt-tab.sh | 6 +- sway/idle.sh | 108 ++-- sway/idlecountdown.pl | 22 +- sway/idlecountdown.sh | 2 +- sway/popup-term.pl | 94 +-- sway/power-menu.sh | 44 +- sway/rotate-wallpaper.sh | 4 +- sway/toggle_outputs.sh | 4 +- sway/wallpaper.pl | 710 ++++++++++++----------- sway/window-fade.pl | 242 ++++---- thinkpad/kbd_backlight.pl | 78 +-- thinkpad/pow.pl | 260 +++++---- thinkpad/user-thinkpad-controls@.service | 4 +- update-firefox.pl | 182 +++--- waybar/toggle-visibility.c | 26 +- waybar/toggle.sh | 38 +- waybar/waybar-audio.sh | 4 +- waybar/waybar-cpu.sh | 4 +- waybar/waybar-debian.sh | 50 +- waybar/waybar-disk.sh | 8 +- waybar/waybar-fedora-silverblue.sh | 50 +- waybar/waybar-gammastep.sh | 82 +-- waybar/waybar-hibernate.sh | 26 +- waybar/waybar-keyboard.sh | 8 +- waybar/waybar-mem.sh | 4 +- waybar/waybar-mpd.sh | 6 +- waybar/waybar-todo.sh | 4 +- waybar/waybar-weather.pl | 34 +- wofi/wofi-alt-tab.sh | 32 +- wofi/wofi-drun.sh | 4 +- wofi/wofi-wifi-menu.sh | 66 +-- 41 files changed, 1221 insertions(+), 1203 deletions(-) diff --git a/audio/stream-podcasts.pl b/audio/stream-podcasts.pl index 1a32d90..77d33d1 100755 --- a/audio/stream-podcasts.pl +++ b/audio/stream-podcasts.pl @@ -9,10 +9,10 @@ use XML::Hash::XS; # CPAN or libxml-hash-xs-perl on Debian # Feeds that should be used if no arguments are provided my @default_feeds = ( - # CBC FrontBurner - "https://www.cbc.ca/podcasting/includes/frontburner.xml", - # Majority Report AM Quickie - "https://feeds.fans.fm/5883fe04-e11e-4578-a018-3b93ddfb5723.xml" + # CBC FrontBurner + "https://www.cbc.ca/podcasting/includes/frontburner.xml", + # Majority Report AM Quickie + "https://feeds.fans.fm/5883fe04-e11e-4578-a018-3b93ddfb5723.xml" ); # Player command (must accept stream as STDIN) @@ -28,14 +28,14 @@ my $player = "> /tmp/fifo.mp3 & omxplayer /tmp/fifo.mp3"; # Multiple feeds can be given as CLI arguments instead my @feeds; if (scalar @ARGV) { - foreach (@ARGV) { - push @feeds, $_; - } + foreach (@ARGV) { + push @feeds, $_; + } } # Only use default feeds if no CLI feeds were given unless (scalar @feeds) { - @feeds = @default_feeds; + @feeds = @default_feeds; } # Local function to get date pattern provided as 'pubDate' @@ -48,36 +48,36 @@ my $xml = XML::Hash::XS->new(utf8 => 0, encoding => 'utf-8'); my @playlist; # Go through each feed foreach my $url (@feeds) { - # Ensure that it's actual an XML link - next unless $url =~ m#^https?://.*\.xml$#; - # Ensure it is fetched okay - my $raw = $ua->get("$url")->content() || next; - # Ensure it is parsed okay - my $xml_hash = $xml->xml2hash($raw) || next; + # Ensure that it's actual an XML link + next unless $url =~ m#^https?://.*\.xml$#; + # Ensure it is fetched okay + my $raw = $ua->get("$url")->content() || next; + # Ensure it is parsed okay + my $xml_hash = $xml->xml2hash($raw) || next; - # Collect all episodes published today - foreach my $item (@{$xml_hash->{'channel'}->{'item'}}) { - if ($item->{'pubDate'} =~ m/$today/) { - # Add any found to playlist - push @playlist, $item->{'enclosure'}->{'url'}; - } + # Collect all episodes published today + foreach my $item (@{$xml_hash->{'channel'}->{'item'}}) { + if ($item->{'pubDate'} =~ m/$today/) { + # Add any found to playlist + push @playlist, $item->{'enclosure'}->{'url'}; } + } } # Fetch each item and pass it to player via STDIN foreach (@playlist) { - # Uncomment the following to print the media URL - print $_ . "\n"; - system("curl -NL $_ $player"); + # Uncomment the following to print the media URL + print $_ . "\n"; + system("curl -NL $_ $player"); } unlink("/tmp/fifo.mp3"); sub get_date { - my ($second, $minute, $hour, $day, $month, $year) = localtime(time); - my @months = ( - 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' - ); - return $day . ' ' . $months[$month] . ' ' . ($year+1900); + my ($second, $minute, $hour, $day, $month, $year) = localtime(time); + my @months = ( + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' + ); + return $day . ' ' . $months[$month] . ' ' . ($year+1900); } diff --git a/distrobox/debian12/gammastep.pl b/distrobox/debian12/gammastep.pl index eb79325..f43cb23 100755 --- a/distrobox/debian12/gammastep.pl +++ b/distrobox/debian12/gammastep.pl @@ -13,41 +13,41 @@ my $lat_lon = fetch_lat_lon($location); my $pid = fork; unless ($pid) { - open(my $fh, ">", $ENV{HOME}."/.spool/gammastep.pid"); - print $fh $$; - close($fh); - open($fh, ">", $ENV{HOME}."/.spool/gammastep.status"); - print $fh 1; - close($fh); + open(my $fh, ">", $ENV{HOME}."/.spool/gammastep.pid"); + print $fh $$; + close($fh); + open($fh, ">", $ENV{HOME}."/.spool/gammastep.status"); + print $fh 1; + close($fh); - open STDIN, '/dev/null'; - open STDOUT, '>>/dev/null'; - open STDERR, '>>/dev/null'; + open STDIN, '/dev/null'; + open STDOUT, '>>/dev/null'; + open STDERR, '>>/dev/null'; - if (! -e "/run/.containerenv" && ! -e "/.dockerenv" ) { - exec "exec /bin/distrobox-enter -n debian12 -- gammastep -l $lat_lon -b 0.7:0.3"; - } else { - exec "exec gammastep -l $lat_lon -b 0.7:0.3"; - } + if (! -e "/run/.containerenv" && ! -e "/.dockerenv" ) { + exec "exec /bin/distrobox-enter -n debian12 -- gammastep -l $lat_lon -b 0.7:0.3"; + } else { + exec "exec gammastep -l $lat_lon -b 0.7:0.3"; + } } sub fetch_lat_lon { - my ($location) = shift; + my ($location) = shift; - my $ua = LWP::UserAgent->new(); - my $json = JSON::XS->new(); + my $ua = LWP::UserAgent->new(); + my $json = JSON::XS->new(); - my $raw = $ua->get($location)->content(); + my $raw = $ua->get($location)->content(); - if (defined $raw) { - my $decoded = $json->decode($raw); - if (defined $decoded->{lat} && defined $decoded->{lon}) { - return "$decoded->{lat}:$decoded->{lon}"; - } + if (defined $raw) { + my $decoded = $json->decode($raw); + if (defined $decoded->{lat} && defined $decoded->{lon}) { + return "$decoded->{lat}:$decoded->{lon}"; } - sleep 5; - return fetch_lat_lon($ua, $json, $location); + } + sleep 5; + return fetch_lat_lon($ua, $json, $location); } exit; diff --git a/distrobox/invalid-terminal.sh b/distrobox/invalid-terminal.sh index 5dab9c8..bf7f765 100755 --- a/distrobox/invalid-terminal.sh +++ b/distrobox/invalid-terminal.sh @@ -6,8 +6,8 @@ echo "Available Distrobox sessions, with matching gnome-terminal profiles, are:" echo "" distrobox list | grep -v 'IMAGE' | cut -d '|' -f 2 for i in 10 9 8 7 6 5 4 3 2 1; do - printf "\rExitting in $i ..." - sleep 1 + printf "\rExitting in $i ..." + sleep 1 done echo "" exit diff --git a/i3/i3move.sh b/i3/i3move.sh index d3e90b8..43e6873 100755 --- a/i3/i3move.sh +++ b/i3/i3move.sh @@ -4,25 +4,25 @@ LAYOUT=`cat ~/.config/screenlayout/i3.current` MIDDLE="eDP-1" if [[ $LAYOUT == 'home' ]]; then - RIGHT="DP-2-2" - LEFT="DP-2-1" + RIGHT="DP-2-2" + LEFT="DP-2-1" elif [[ $LAYOUT == 'work' ]]; then - RIGHT="DP-2-2" - LEFT="DP-2-1" + RIGHT="DP-2-2" + LEFT="DP-2-1" elif [[ $LAYOUT == '3' ]]; then - MIDDLE="DP-2-2" - LEFT="DP-2-1" - RIGHT="eDP-1" + MIDDLE="DP-2-2" + LEFT="DP-2-1" + RIGHT="eDP-1" else - echo "No external displays connected" + echo "No external displays connected" fi if [[ $1 == 'right' ]]; then - i3 move workspace to output $RIGHT + i3 move workspace to output $RIGHT elif [[ $1 == 'middle' ]]; then - i3 move workspace to output $MIDDLE + i3 move workspace to output $MIDDLE elif [[ $1 == 'left' ]]; then - i3 move workspace to output $LEFT + i3 move workspace to output $LEFT else - echo "Invalid direction. Requires either 'up', 'left', or 'middle'" + echo "Invalid direction. Requires either 'up', 'left', or 'middle'" fi diff --git a/rofi/drun.sh b/rofi/drun.sh index 490d1e3..c99d38e 100755 --- a/rofi/drun.sh +++ b/rofi/drun.sh @@ -4,7 +4,7 @@ ROFI=$(pgrep -xc rofi | cut -b 1) echo $ROFI if [[ "$ROFI" -eq "0" ]]; then - rofi -config /home/jpm/.config/rofi/config.rasi -theme /home/jpm/.config/rofi/sidebar.rasi -show drun -lines 20 + rofi -config /home/jpm/.config/rofi/config.rasi -theme /home/jpm/.config/rofi/sidebar.rasi -show drun -lines 20 else - killall rofi 2&>1 /dev/null + killall rofi 2&>1 /dev/null fi diff --git a/rofi/rofi-openvpn.sh b/rofi/rofi-openvpn.sh index b8144c6..95ea4b6 100755 --- a/rofi/rofi-openvpn.sh +++ b/rofi/rofi-openvpn.sh @@ -5,25 +5,25 @@ res=$(echo "Connection|John.Me.tz|MailCleaner|Disconnect|Restart" | rofi -sep "|" -dmenu -i -p 'P ' "" -columns 9 -width 45 -l 1 -config /home/jpm/.config/rofi/config.rasi -theme /home/jpm/.config/rofi/sidebar -hide-scrollbar -eh 1 -location 0 -auto-select -no-fullscreen) if [ $res = "Connection" ]; then - /usr/bin/uxterm -e 'sudo /usr/bin/nmtui' + /usr/bin/uxterm -e 'sudo /usr/bin/nmtui' elif [ $res = "John.Me.tz" ]; then - sudo /usr/bin/systemctl stop openvpn-client@mailcleaner - sudo /usr/bin/systemctl restart wg-quick@wg0 + sudo /usr/bin/systemctl stop openvpn-client@mailcleaner + sudo /usr/bin/systemctl restart wg-quick@wg0 elif [ $res = "MailCleaner" ]; then - sudo /usr/bin/systemctl stop wg-quick@wg0 - sudo /usr/bin/systemctl restart openvpn-client@mailcleaner + sudo /usr/bin/systemctl stop wg-quick@wg0 + sudo /usr/bin/systemctl restart openvpn-client@mailcleaner elif [ $res = "Disconnect" ]; then - sudo /usr/bin/systemctl stop openvpn-client@mailcleaner - sudo /usr/bin/systemctl stop wg-quick@wg0 + sudo /usr/bin/systemctl stop openvpn-client@mailcleaner + sudo /usr/bin/systemctl stop wg-quick@wg0 elif [ $res = "Restart" ]; then - if [ "`ip addr show wg0 2> /dev/null`" != "" ]; then - sudo /usr/bin/systemctl restart wg-quick@wg0 - fi - if [ "`ip addr show tun0 2> /dev/null`" != "" ]; then - sudo /usr/bin/systemctl restart openvpn-client@mailcleaner - fi + if [ "`ip addr show wg0 2> /dev/null`" != "" ]; then + sudo /usr/bin/systemctl restart wg-quick@wg0 + fi + if [ "`ip addr show tun0 2> /dev/null`" != "" ]; then + sudo /usr/bin/systemctl restart openvpn-client@mailcleaner + fi else - exit + exit fi # Waybar sometimes doesn't update with the VPN IP, for whatever reason. Restart it. diff --git a/rofi/rofi-send-to-kodi.sh b/rofi/rofi-send-to-kodi.sh index 2ff08c0..5d3682c 100755 --- a/rofi/rofi-send-to-kodi.sh +++ b/rofi/rofi-send-to-kodi.sh @@ -1,7 +1,7 @@ #!/bin/bash INPUT="$(rofi -dmenu -i -p 'Kodi:' "" -columns 1 -rows 7 -width 32 -l 1 \ - -theme /home/jpm/.config/rofi/sidebar.rasi -hide-scrollbar -eh 1 -location \ - 0 -padding 12 -opacity 100)" + -theme /home/jpm/.config/rofi/sidebar.rasi -hide-scrollbar -eh 1 -location \ + 0 -padding 12 -opacity 100)" /home/jpm/scripts/send-to-kodi.sh $INPUT 2>&1 /dev/null diff --git a/rofi/rofi-ssh-menu.sh b/rofi/rofi-ssh-menu.sh index ae237d9..7e44286 100755 --- a/rofi/rofi-ssh-menu.sh +++ b/rofi/rofi-ssh-menu.sh @@ -10,32 +10,32 @@ rofi -sep "|" -dmenu -i -p 'P ' "" -columns 1 -rows 1 -width 45 -l 1 -config \ echo $res > /home/jpm/.last_ssh_shortcut if [ $res = "john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs w' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs w' elif [ $res = "root@john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs r' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs r' elif [ $res = "shb.ng" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs s' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs s' elif [ $res = "kipary.fastnet.ch" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs d' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs d' elif [ $res = "camera.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs c' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs c' elif [ $res = "hud.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs h' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs h' elif [ $res = "media.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs m' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs m' elif [ $res = "programmer.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs p' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs p' elif [ $res = "t470s.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs l' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs l' elif [ $res = "therm.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs t' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs t' elif [ $res = "vm.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs v' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs v' elif [ $res = "light.lan.john.me.tz" ]; then - /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs light' + /usr/bin/urxvt -e /bin/bash -c '/home/jpm/scripts/sshs light' elif [ $res = "mac.lan.john.me.tz" ]; then - /usr/bin/gvncviewer 192.168.2.10 >> /home/jpm/macos + /usr/bin/gvncviewer 192.168.2.10 >> /home/jpm/macos elif [ $res = "AndroidUSB" ]; then - /usr/bin/scrcpy + /usr/bin/scrcpy fi exit 0 diff --git a/rofi/rofi-sway-rotate.sh b/rofi/rofi-sway-rotate.sh index 4e617f9..9b67582 100755 --- a/rofi/rofi-sway-rotate.sh +++ b/rofi/rofi-sway-rotate.sh @@ -4,13 +4,13 @@ res=$(echo "Rotate 0 (Normal)|Rotate 90 (Keyboard right)|Rotate 180 (Upside-down)|Rotate 270 (Keyborad left)" | rofi -sep "|" -dmenu -i -p 'P ' "" -columns 9 -width 45 -l 1 -config /home/jpm/.config/rofi/config.rasi -theme /home/jpm/.config/rofi/sidebar.rasi -hide-scrollbar -eh 1 -location 0 -auto-select -no-fullscreen) if [[ $res == "Rotate 0 (Normal)" ]]; then - swaymsg output eDP-1 transform 0 + swaymsg output eDP-1 transform 0 elif [[ $res == "Rotate 90 (Keyboard right)" ]]; then - swaymsg output eDP-1 transform 90 + swaymsg output eDP-1 transform 90 elif [[ $res == "Rotate 180 (Upside-down)" ]]; then - swaymsg output eDP-1 transform 180 + swaymsg output eDP-1 transform 180 elif [[ $res == "Rotate 270 (Keyboard left)" ]]; then - swaymsg output eDP-1 transform 270 + swaymsg output eDP-1 transform 270 else - exit + exit fi diff --git a/rofi/rofi-yubioath.sh b/rofi/rofi-yubioath.sh index 04467b5..fd9cd22 100755 --- a/rofi/rofi-yubioath.sh +++ b/rofi/rofi-yubioath.sh @@ -3,10 +3,10 @@ RUNNING=$(pgrep yubioath-deskto) if [ "$RUNNING" ]; then - kill $RUNNING - sudo systemctl stop pcscd.socket - sudo systemctl restart pcscd.service - sudo systemctl start pcscd.socket + kill $RUNNING + sudo systemctl stop pcscd.socket + sudo systemctl restart pcscd.service + sudo systemctl start pcscd.socket fi QT_QPA_PLATFORMTHEME=qt5ct QT_QPA_PLATFORM=wayland QT_PLUGIN_PATH=/usr/lib/qt/plugins /usr/bin/yubioath-desktop & diff --git a/rofi/sway-alt-tab.sh b/rofi/sway-alt-tab.sh index bc1f56b..23b8149 100755 --- a/rofi/sway-alt-tab.sh +++ b/rofi/sway-alt-tab.sh @@ -9,10 +9,10 @@ sed -e 's/^\([0-9]*\)\t*\(.*\)/\2 \1/' | rofi -dmenu -config ~/.config/rofi/sidebar.rasi | { - read -r + read -r - id=`echo $REPLY | rev | cut -d' ' -f1 | rev` + id=`echo $REPLY | rev | cut -d' ' -f1 | rev` - swaymsg "[con_id=$id]" focus + swaymsg "[con_id=$id]" focus } diff --git a/sway/idle.sh b/sway/idle.sh index 193e767..88027ef 100755 --- a/sway/idle.sh +++ b/sway/idle.sh @@ -12,74 +12,74 @@ SUSPEND_TIMEOUT=3600 # one hour function usage() { - echo "usage: $0