Moves scripts to own folder

This commit is contained in:
Michel Fedde 2025-06-07 20:47:27 +02:00
parent 36dbfbc689
commit bcb83fb7be
32 changed files with 69 additions and 645 deletions

7
.config/scripts/LockScreen.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# For Hyprlock
pidof hyprlock || hyprlock -q

86
.config/scripts/MediaCtrl.sh Executable file
View file

@ -0,0 +1,86 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Playerctl
iconPath="/usr/share/icons/Qogir/24/actions"
nextIcon="$iconPath/gtk-media-next-ltr.svg"
previousIcon="$iconPath/gtk-media-previous-ltr.svg"
stopIcon="$iconPath/gtk-media-stop.svg"
playIcon="$iconPath/gtk-media-play-ltr.svg"
pauseIcon="$iconPath/gtk-media-pause.svg"
# Play the next track
play_next() {
playerctl next
show_music_notification next
}
# Play the previous track
play_previous() {
playerctl previous
show_music_notification previous
}
# Toggle play/pause
toggle_play_pause() {
playerctl play-pause
show_music_notification toggle
}
# Stop playback
stop_playback() {
playerctl stop
notify-send -e -u low -i $stopIcon " Playback:" " Stopped"
}
# Display notification with song information
show_music_notification() {
sleep 0.5s
status=$(playerctl status)
icon=""
case "$1" in
"next")
icon=$nextIcon
;;
"previous")
icon=$previousIcon
;;
"toggle")
if [[ "$status" == "Paused" ]]; then
icon=$pauseIcon
else
icon=$playIcon
fi
;;
esac
if [[ "$status" == "Playing" ]]; then
song_title=$(playerctl metadata title)
song_artist=$(playerctl metadata artist)
notify-send -e -u low -i $icon "Now Playing:" "$song_title by $song_artist"
elif [[ "$status" == "Paused" ]]; then
notify-send -e -u low -i $icon " Playback:" " Paused"
fi
}
# Get media control action from command line argument
case "$1" in
"--nxt")
play_next
;;
"--prv")
play_previous
;;
"--pause")
toggle_play_pause
;;
"--stop")
stop_playback
;;
*)
echo "Usage: $0 [--nxt|--prv|--pause|--stop]"
exit 1
;;
esac

148
.config/scripts/ScreenShot.sh Executable file
View file

@ -0,0 +1,148 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Screenshots scripts
time=$(date "+%d-%b_%H-%M-%S")
dir="$(xdg-user-dir)/Pictures/Screenshots"
file="Screenshot_${time}_${RANDOM}.png"
active_window_class=$(hyprctl -j activewindow | jq -r '(.class)')
active_window_file="Screenshot_${time}_${active_window_class}.png"
active_window_path="${dir}/${active_window_file}"
notify_cmd_base="notify-send -t 10000 -A action1=Open -A action2=Delete -h string:x-canonical-private-synchronous:shot-notify"
#notify_swappy="notify-send -h string:x-canonical-private-synchronous:shot-notify -u low -i ${iDIR}/picture.png"
notify_cmd_shot="${notify_cmd_base}"
notify_cmd_shot_win="${notify_cmd_base}"
# notify and view screenshot
notify_view() {
if [[ "$1" == "active" ]]; then
if [[ -e "${active_window_path}" ]]; then
resp=$(timeout 5 ${notify_cmd_shot_win} " Screenshot of:" " ${active_window_class} Saved.")
case "$resp" in
action1)
xdg-open "${active_window_path}" &
;;
action2)
rm "${active_window_path}" &
;;
esac
else
${notify_cmd_shot} " Screenshot of:" " ${active_window_class} NOT Saved."
"${sDIR}/Sounds.sh" --error
fi
elif [[ "$1" == "swappy" ]]; then
resp=$(${notify_cmd_shot} " Screenshot:" " Captured by Swappy")
case "$resp" in
action1)
swappy -f - <"$tmpfile"
;;
action2)
rm "$tmpfile"
;;
esac
else
local check_file="${dir}/${file}"
if [[ -e "$check_file" ]]; then
resp=$(timeout 5 ${notify_cmd_shot} " Screenshot" " Saved")
case "$resp" in
action1)
xdg-open "${check_file}" &
;;
action2)
rm "${check_file}" &
;;
esac
else
${notify_cmd_shot} " Screenshot" " NOT Saved"
"${sDIR}/Sounds.sh" --error
fi
fi
}
# countdown
countdown() {
for sec in $(seq $1 -1 1); do
notify-send -h string:x-canonical-private-synchronous:shot-notify -t 1000 -i "$iDIR"/timer.png " Taking shot" " in: $sec secs"
sleep 1
done
}
# take shots
shotnow() {
cd ${dir} && grim - | tee "$file" | wl-copy
sleep 2
notify_view
}
shot5() {
countdown '5'
sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy
sleep 1
notify_view
}
shot10() {
countdown '10'
sleep 1 && cd ${dir} && grim - | tee "$file" | wl-copy
notify_view
}
shotwin() {
w_pos=$(hyprctl activewindow | grep 'at:' | cut -d':' -f2 | tr -d ' ' | tail -n1)
w_size=$(hyprctl activewindow | grep 'size:' | cut -d':' -f2 | tr -d ' ' | tail -n1 | sed s/,/x/g)
cd ${dir} && grim -g "$w_pos $w_size" - | tee "$file" | wl-copy
notify_view
}
shotarea() {
tmpfile=$(mktemp)
grim -g "$(slurp)" - >"$tmpfile"
if [[ -s "$tmpfile" ]]; then
wl-copy <"$tmpfile"
mv "$tmpfile" "$dir/$file"
fi
notify_view
}
shotactive() {
active_window_class=$(hyprctl -j activewindow | jq -r '(.class)')
active_window_file="Screenshot_${time}_${active_window_class}.png"
active_window_path="${dir}/${active_window_file}"
hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | grim -g - "${active_window_path}"
sleep 1
notify_view "active"
}
shotswappy() {
tmpfile=$(mktemp)
grim -g "$(slurp)" - >"$tmpfile" && notify_view "swappy"
}
if [[ ! -d "$dir" ]]; then
mkdir -p "$dir"
fi
if [[ "$1" == "--now" ]]; then
shotnow
elif [[ "$1" == "--in5" ]]; then
shot5
elif [[ "$1" == "--in10" ]]; then
shot10
elif [[ "$1" == "--win" ]]; then
shotwin
elif [[ "$1" == "--area" ]]; then
shotarea
elif [[ "$1" == "--active" ]]; then
shotactive
elif [[ "$1" == "--swappy" ]]; then
shotswappy
else
echo -e "Available Options : --now --in5 --in10 --win --area --active --swappy"
fi
exit 0

143
.config/scripts/Volume.sh Executable file
View file

@ -0,0 +1,143 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Scripts for volume controls for audio and mic
iDIR="/usr/share/icons/Qogir/24/actions"
sDIR="$HOME/.config/hypr/scripts"
# Get Volume
get_volume() {
volume=$(pamixer --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume %"
fi
}
# Get icons
get_icon() {
current=$(get_volume)
if [[ "$current" == "Muted" ]]; then
echo "$iDIR/audio-volume-muted.svg"
elif [[ "${current%\%}" -le 30 ]]; then
echo "$iDIR/audio-volume-low.svg"
elif [[ "${current%\%}" -le 60 ]]; then
echo "$iDIR/audio-volume-medium.svg"
else
echo "$iDIR/audio-volume-high.svg"
fi
}
# Notify
notify_user() {
if [[ "$(get_volume)" == "Muted" ]]; then
notify-send -e -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" " Volume:" " Muted"
else
notify-send -e -h int:value:"$(get_volume | sed 's/%//')" -h string:x-canonical-private-synchronous:volume_notif -u low -i "$(get_icon)" " Volume Level:" " $(get_volume)" &&
"$sDIR/Sounds.sh" --volume
fi
}
# Increase Volume
inc_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
toggle_mute
else
pamixer -i 5 --allow-boost --set-limit 150 && notify_user
fi
}
# Decrease Volume
dec_volume() {
if [ "$(pamixer --get-mute)" == "true" ]; then
toggle_mute
else
pamixer -d 5 && notify_user
fi
}
# Toggle Mute
toggle_mute() {
if [ "$(pamixer --get-mute)" == "false" ]; then
pamixer -m && notify-send -e -u low -i "$iDIR/audio-volume-muted.svg" " Mute"
elif [ "$(pamixer --get-mute)" == "true" ]; then
pamixer -u && notify-send -e -u low -i "$(get_icon)" " Volume:" " Switched ON"
fi
}
# Toggle Mic
toggle_mic() {
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
pamixer --default-source -m && notify-send -e -u low -i "$iDIR/microphone-mute.png" " Microphone:" " Switched OFF"
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
pamixer -u --default-source u && notify-send -e -u low -i "$iDIR/microphone.png" " Microphone:" " Switched ON"
fi
}
# Get Mic Icon
get_mic_icon() {
current=$(pamixer --default-source --get-volume)
if [[ "$current" -eq "0" ]]; then
echo "$iDIR/microphone-mute.png"
else
echo "$iDIR/microphone.png"
fi
}
# Get Microphone Volume
get_mic_volume() {
volume=$(pamixer --default-source --get-volume)
if [[ "$volume" -eq "0" ]]; then
echo "Muted"
else
echo "$volume %"
fi
}
# Notify for Microphone
notify_mic_user() {
volume=$(get_mic_volume)
icon=$(get_mic_icon)
notify-send -e -h int:value:"$volume" -h "string:x-canonical-private-synchronous:volume_notif" -u low -i "$icon" " Mic Level:" " $volume"
}
# Increase MIC Volume
inc_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
toggle_mic
else
pamixer --default-source -i 5 && notify_mic_user
fi
}
# Decrease MIC Volume
dec_mic_volume() {
if [ "$(pamixer --default-source --get-mute)" == "true" ]; then
toggle-mic
else
pamixer --default-source -d 5 && notify_mic_user
fi
}
# Execute accordingly
if [[ "$1" == "--get" ]]; then
get_volume
elif [[ "$1" == "--inc" ]]; then
inc_volume
elif [[ "$1" == "--dec" ]]; then
dec_volume
elif [[ "$1" == "--toggle" ]]; then
toggle_mute
elif [[ "$1" == "--toggle-mic" ]]; then
toggle_mic
elif [[ "$1" == "--get-icon" ]]; then
get_icon
elif [[ "$1" == "--get-mic-icon" ]]; then
get_mic_icon
elif [[ "$1" == "--mic-inc" ]]; then
inc_mic_volume
elif [[ "$1" == "--mic-dec" ]]; then
dec_mic_volume
else
get_volume
fi

38
.config/scripts/WaybarCava.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# Not my own work. This was added through Github PR. Credit to original author
#----- Optimized bars animation without much CPU usage increase --------
bar="▁▂▃▄▅▆▇█"
dict="s/;//g"
# Calculate the length of the bar outside the loop
bar_length=${#bar}
# Create dictionary to replace char with bar
for ((i = 0; i < bar_length; i++)); do
dict+=";s/$i/${bar:$i:1}/g"
done
# Create cava config
config_file="/tmp/bar_cava_config"
cat >"$config_file" <<EOF
[general]
bars = 10
[input]
method = pulse
source = auto
[output]
method = raw
raw_target = /dev/stdout
data_format = ascii
ascii_max_range = 7
EOF
# Kill cava if it's already running
pkill -f "cava -p $config_file"
# Read stdout from cava and perform substitution in a single sed command
cava -p "$config_file" | sed -u "$dict"

88
.config/scripts/Weather.sh Executable file
View file

@ -0,0 +1,88 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ##
# weather info from wttr. https://github.com/chubin/wttr.in
# Remember to add city
city=
cachedir=~/.cache/rbn
cachefile=${0##*/}-$1
if [ ! -d $cachedir ]; then
mkdir -p $cachedir
fi
if [ ! -f $cachedir/$cachefile ]; then
touch $cachedir/$cachefile
fi
# Save current IFS
SAVEIFS=$IFS
# Change IFS to new line.
IFS=$'\n'
cacheage=$(($(date +%s) - $(stat -c '%Y' "$cachedir/$cachefile")))
if [ $cacheage -gt 1740 ] || [ ! -s $cachedir/$cachefile ]; then
data=($(curl -s https://en.wttr.in/"$city"$1\?0qnT 2>&1))
echo ${data[0]} | cut -f1 -d, >$cachedir/$cachefile
echo ${data[1]} | sed -E 's/^.{15}//' >>$cachedir/$cachefile
echo ${data[2]} | sed -E 's/^.{15}//' >>$cachedir/$cachefile
fi
weather=($(cat $cachedir/$cachefile))
# Restore IFSClear
IFS=$SAVEIFS
temperature=$(echo ${weather[2]} | sed -E 's/([[:digit:]]+)\.\./\1 to /g')
#echo ${weather[1]##*,}
# https://fontawesome.com/icons?s=solid&c=weather
case $(echo ${weather[1]##*,} | tr '[:upper:]' '[:lower:]') in
"clear" | "sunny")
condition=""
;;
"partly cloudy")
condition="󰖕"
;;
"cloudy")
condition=""
;;
"overcast")
condition=""
;;
"fog" | "freezing fog")
condition=""
;;
"patchy rain possible" | "patchy light drizzle" | "light drizzle" | "patchy light rain" | "light rain" | "light rain shower" | "mist" | "rain")
condition="󰼳"
;;
"moderate rain at times" | "moderate rain" | "heavy rain at times" | "heavy rain" | "moderate or heavy rain shower" | "torrential rain shower" | "rain shower")
condition=""
;;
"patchy snow possible" | "patchy sleet possible" | "patchy freezing drizzle possible" | "freezing drizzle" | "heavy freezing drizzle" | "light freezing rain" | "moderate or heavy freezing rain" | "light sleet" | "ice pellets" | "light sleet showers" | "moderate or heavy sleet showers")
condition="󰼴"
;;
"blowing snow" | "moderate or heavy sleet" | "patchy light snow" | "light snow" | "light snow showers")
condition="󰙿"
;;
"blizzard" | "patchy moderate snow" | "moderate snow" | "patchy heavy snow" | "heavy snow" | "moderate or heavy snow with thunder" | "moderate or heavy snow showers")
condition=""
;;
"thundery outbreaks possible" | "patchy light rain with thunder" | "moderate or heavy rain with thunder" | "patchy light snow with thunder")
condition=""
;;
*)
condition=""
echo -e "{\"text\":\""$condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
;;
esac
#echo $temp $condition
echo -e "{\"text\":\""$temperature $condition"\", \"alt\":\""${weather[0]}"\", \"tooltip\":\""${weather[0]}: $temperature ${weather[1]}"\"}"
cached_weather="$temperature \n$condition ${weather[1]}"
echo -e $cached_weather >~/.cache/.weather_cache

View file

@ -0,0 +1,42 @@
#!/bin/env sh
declare -A actions
actions['Sync']="sync"
actions["Logout"]="logout"
actions["Lock"]="lock"
printSelection() {
echo "$1"
for key in "${!fruits[@]}"
do
echo "Action: $key"
done
}
formattedIDs=$(echo "format:[NAME] ([USERNAME])" | nc -U /tmp/bitwarden-daemon.sock)
selectionList=$(echo "$formattedIDs" | jq 'keys | map("\(.)\n") | add' -r)
actionSelectionList=$(printf "Actions: %s\n" ${!actions[@]})
selection=$(printf "%s\n" "$selectionList" "$actionSelectionList" | anyrun --plugins libstdin.so)
echo "$selection"
if [[ $selection == '' ]]; then
exit 0
fi
if [[ $selection == Actions:* ]]; then
actionKey="${selection:9}"
action="${actions[$actionKey]}"
echo "Performing: $action"
echo "$action:" | nc -U /tmp/bitwarden-daemon.sock
else
id=$(echo "$formattedIDs" | jq ".[\"${selection}\"]" -r)
echo "lookupPassword:$id" | nc -U /tmp/bitwarden-daemon.sock | wl-copy
notify-send "Password copied" "Copied password for '$selection' to clipboard."
fi
exit 0;

View file

@ -0,0 +1,15 @@
#!/bin/env sh
SCRIPTS_DIR="$HOME/.config/hypr/scripts"
declare -A scripts
scripts["Shutdown"]="systemctl poweroff"
scripts["Reboot"]="systemctl reboot"
scripts["Logout"]="logout terminate-user $USER"
scripts["Lock"]="$SCRIPTS_DIR/LockScreen.sh"
scripts["Notification Center (SwayNC)"]="swaync-client -t -sw"
selected=$(printf "%s\n" "${!scripts[@]}" | anyrun --plugins libstdin.so)
command="${scripts[$selected]}"
$command