feat: Add a few more scripts

This commit is contained in:
Nathan Woodburn 2024-10-16 17:46:26 +11:00
parent 6d8bbe058a
commit c6f72095cb
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
5 changed files with 106 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
powertop/
libtracefs/
libtraceevent/
weather.sh

5
close_window.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
window_id=$(xdotool getwindowfocus)
# xdotool windowclose $window_id
xdotool windowactivate --sync $window_id key --clearmodifiers --delay 100 alt+F4

View File

@ -97,9 +97,9 @@ if [ "$active_count" -eq 1 ]; then
title=$(playerctl -p "$brave" metadata --format '{{title}}')
truncated_title=$(truncate_string "$title" $(($MAX_TITLE_LENGTH + $MAX_ARTIST_LENGTH)))
if [ "$status" == "Paused" ]; then
echo "🎵 $truncated_title (Paused)"
echo "󰝚 $truncated_title (Paused)"
else
echo "🎵 $truncated_title"
echo "󰝚 $truncated_title"
fi
exit 0
fi
@ -108,9 +108,9 @@ if [ "$active_count" -eq 1 ]; then
truncated_artist=$(truncate_string "$artist" $MAX_ARTIST_LENGTH)
if [ "$status" == "Paused" ]; then
echo "🎵 $truncated_title [$truncated_artist] (Paused)"
echo "󰝚 $truncated_title [$truncated_artist] (Paused)"
else
echo "🎵 $truncated_title [$truncated_artist]"
echo "󰝚 $truncated_title [$truncated_artist]"
fi
elif [ "$active_count" -gt 1 ]; then
@ -126,12 +126,12 @@ elif [ "$active_count" -gt 1 ]; then
if [ "$title" == "Vilos" ]; then
title=$(playerctl -p "$brave" metadata --format '{{title}}')
truncated_title=$(truncate_string "$title" $(($MAX_TITLE_LENGTH + $MAX_ARTIST_LENGTH)))
output+="🎵 $truncated_title"
output+="󰝚 $truncated_title"
else
artist=$(playerctl -p "$player" metadata --format '{{artist}}')
truncated_title=$(truncate_string "$title" $MAX_TITLE_LENGTH)
truncated_artist=$(truncate_string "$artist" $MAX_ARTIST_LENGTH)
output+="🎵 $truncated_title [$truncated_artist]"
output+="󰝚 $truncated_title [$truncated_artist]"
fi
if [ "$verbose" -eq 1 ]; then
echo "Player $player: $title - $artist"
@ -173,16 +173,16 @@ elif [ "$active_count" -gt 1 ]; then
truncated_title=$(truncate_string "$title" $(($MAX_TITLE_LENGTH + $MAX_ARTIST_LENGTH)))
if [ "$brave_status" == "Playing" ]; then
echo "🎵 $truncated_title"
echo "󰝚 $truncated_title"
else
echo "🎵 $truncated_title (Paused)"
echo "󰝚 $truncated_title (Paused)"
fi
exit 0
fi
truncated_title=$(truncate_string "$title" $MAX_TITLE_LENGTH)
truncated_artist=$(truncate_string "$artist" $MAX_ARTIST_LENGTH)
output="🎵 $truncated_title [$truncated_artist]"
output="󰝚 $truncated_title [$truncated_artist]"
if [ "$brave_status" == "Playing" ]; then
echo "$output"
else
@ -199,8 +199,8 @@ else
fi
brave_status=$(playerctl -p "$brave" status 2>/dev/null)
title=$(playerctl -p "$brave" metadata --format '{{title}}')
artist=$(playerctl -p "$brave" metadata --format '{{artist}}')
title=$(playerctl -p "$brave" metadata --format '{{title}}' 2>/dev/null)
artist=$(playerctl -p "$brave" metadata --format '{{artist}}' 2>/dev/null)
# Print the title and artist
if [ "$verbose" -eq 1 ]; then
echo "Brave is playing"
@ -211,21 +211,25 @@ else
# Check if artist is empty
if [ -z "$artist" ]; then
if [ -z "$title" ]; then
if [ "$verbose" -eq 1 ]; then
echo "No metadata found"
fi
echo ""
exit 0
fi
truncated_title=$(truncate_string "$title" $(($MAX_TITLE_LENGTH + $MAX_ARTIST_LENGTH)))
if [ "$brave_status" == "Playing" ]; then
echo "🎵 $truncated_title"
echo "󰝚 $truncated_title"
else
echo "🎵 $truncated_title (Paused)"
echo "󰝚 $truncated_title (Paused)"
fi
exit 0
fi
truncated_title=$(truncate_string "$title" $MAX_TITLE_LENGTH)
truncated_artist=$(truncate_string "$artist" $MAX_ARTIST_LENGTH)
output="🎵 $truncated_title [$truncated_artist]"
output="󰝚 $truncated_title [$truncated_artist]"
if [ "$brave_status" == "Playing" ]; then
echo "$output"
else

59
storage.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/bash
# Storage locations to check
locations=(
"/home/nathan"
"/home/nathan/Nextcloud"
)
icons=(
"󰋜"
""
)
# Check for first arg
if [ -z "$1" ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check if storage is full
for i in "${!locations[@]}"; do
# Check if the location exists
location=${locations[$i]}
if [ -d "$location" ]; then
# Get icon for location
icon=${icons[$i]}
# Get the current usage
size=$(du -hs "$location" | awk '{print $1}')
echo -en "${YELLOW}${icon} ${NC}${size} "
fi
done
echo ""
else
RED='%{F#ff0000}'
GREEN='%{F#ff60d090}'
YELLOW='%{F#F0C674}'
BLUE='%{F#0000ff}'
NC='%{F-}'
# Check if storage is full
for i in "${!locations[@]}"; do
# Check if the location exists
location=${locations[$i]}
if [ -d "$location" ]; then
# Get icon for location
icon=${icons[$i]}
# Get the current usage (discard error output)
size=$(du -hs "$location" 2>/dev/null | awk '{print $1}')
echo -en "%{A1:/home/nathan/scripts/zellij.sh --cwd $location zsh:}${YELLOW}${icon} ${NC}${size}%{A} "
fi
done
echo ""
fi

23
zellij.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Check if focus on zellig window worked wmctrl -a zellij
if [ -z "$(wmctrl -l | grep Zellij)" ]; then
echo "No terminal running" > /tmp/message
polybar-msg action message hook 0
else
wmctrl -a Zellij
fi
# Get arguments and run in new zellij pane
if [ "$#" -ne 0 ];
then
# Check if --cwd flag is passed
if [ "$1" == "--cwd" ];
then
zellij run -fc --cwd "$2" -- "${@:3}"
else
zellij run -fc -- "$@"
fi
else
echo "Usage: zelij.sh <command>"
fi