diff --git a/.scripts/refresh b/.scripts/refresh new file mode 100755 index 0000000..7cc5538 --- /dev/null +++ b/.scripts/refresh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash + +# ─< scriptdir declaration >────────────────────────────────────────────────────────────── +SCRIPTS="$HOME/.config/hypr/.scripts" + +# ─< Check if the given command exists silently >───────────────────────────────────────── +command_exists() { + command -v "$@" >/dev/null 2>&1 +} + +_kill_() { + # ─< Kill already running processes >───────────────────────────────────────────────────── + hyprpanel="gjs" # since hyprpanel has so many different wordings, making it clear that this is currently the hyprpanel service name + _ps=(gBar wofi swaync waybar $hyprpanel) + for _prs in "${_ps[@]}"; do + if pidof "${_prs}" >/dev/null; then + pkill "${_prs}" + fi + done +} + +_redshift() { + . $SCRIPTS/redshift.sh && notify-send -u low "󰴅" "Redshift active" +} + +# ─< Relaunch waybar >──────────────────────────────────────────────────────────────────── +pywall_waybar() { + notify-send -u low "Bar" "waybar is launching with wal.." + waybar --style $HOME/.config/waybar/pywal_style.css +} + +_hyprpanel() { + notify-send -u low "Bar" "hyprpanel is loading.." + hyprpanel & +} + +_waybar() { + if command_exists wal; then + pywall_waybar + else + notify-send -u normal "Bar" "waybar is loading.." + waybar --config $HOME/.config/waybar/ai_config.jsonc --style $HOME/.config/waybar/ai_style.css & + fi +} + +# ─< Relaunch gBar >────────────────────────────────────────────────────────────────────── +_gBar() { + notify-send -u low "Bar" "gBar is loading.." + gBar bar 0 & + gBar bar 1 & +} + +_bar() { + if command_exists hyprpanel; then + _hyprpanel + elif command_exists gBar; then + _gBar + elif command_exists waybar; then + _waybar + else + notify-send -u critical "ERROR" "No 'bar'-provider found! Install either hyprpanel, gBar or waybar!" + fi +} + +# # for cava-pywal (note, need to manually restart cava once wallpaper changes) +# # ln -sf "$HOME/.cache/wal/cava-colors" "$HOME/.config/cava/config" || true +# if [ -d "$HOME/.cache/wal/" ]; then +# ln -sf "$HOME/.cache/wal/colors-rofi-dark.rasi" "$HOME/.config/rofi/pywal-color/pywal-theme.rasi" || true +# if [ -e "$HOME/.config/waybar/pywal.css" ]; then +# rm $HOME/.config/waybar/pywal.css +# command cat $HOME/.cache/wal/colors.css >$HOME/.config/waybar/pywal.css +# # pywall_waybar || _waybar +# _gBar +# else +# # _waybar +# _gBar +# fi +# else +# # _waybar +# _gBar +# notify-send -u critical "ERROR" "critical failure! wal is not present!!" +# fi + +main() { + + # notify-send "low" "terminating main wm elements" + _kill_ + + # relaunch swaync + sleep 0.3 + + hyprctl reload + + sleep 0.2 + # swaync >/dev/null 2>&1 & + # notify-send "low" "bar" "launching.." + bash "$SCRIPTS/bar" + + notify-send "low" "wallpaper" "loading.." + bash "$SCRIPTS/wallpaper" + + if command_exists redshift; then + notify-send "low" "redshift" "protecting your eyes from the blue light.." + _redshift + fi + + exit 0 +} + +main