From 91172400880a5e3a613fb70477ffe869bbfaf7e2 Mon Sep 17 00:00:00 2001 From: pika Date: Thu, 19 Jun 2025 15:20:20 +0200 Subject: [PATCH] wip --- hotkeys.conf | 2 +- hyprland.conf | 8 ++++-- scripts/bar | 72 +++++++++++++++++++---------------------------- scripts/init | 37 +++++++++++------------- scripts/refresh | 62 ++-------------------------------------- scripts/wallpaper | 51 +++++++++++++++++++++++++-------- 6 files changed, 93 insertions(+), 139 deletions(-) diff --git a/hotkeys.conf b/hotkeys.conf index ae81d84..e04556a 100644 --- a/hotkeys.conf +++ b/hotkeys.conf @@ -33,7 +33,7 @@ device { } # ─────────────────< See https://wiki.hyprland.org/Configuring/Keywords/ >─────────────── -$SCRIPTS = ~/.config/hypr/.scripts +$SCRIPTS = ~/.config/hypr/scripts # ─< set mod key >──────────────────────────────────────────────────────────────────────── $mainMod = ALT # Sets "ALT" key as main modifier diff --git a/hyprland.conf b/hyprland.conf index 23f0725..4cb1639 100644 --- a/hyprland.conf +++ b/hyprland.conf @@ -28,10 +28,9 @@ source = $confDirHyprland/auto-exec.conf source = $HOME/.monitors.conf # variable for specialworkspace (has to be configured in .monitors.conf like -> 'workspace = name:x, on-created-empty:$terminal') -# $terminal = foot -# $browser = zen-browser - +# SINGLE MONITOR SETUP: # $secondary = $main # <- Uncomment this, if you only have one monitor + # ─< main-workspaces >──────────────────────────────────────────────────────────────────────────── workspace = 1, monitor:$main, persitent:true workspace = 2, monitor:$secondary, persitent:true @@ -106,6 +105,9 @@ windowrule = nodim, initialClass:zen windowrule = opaque, initialClass:(Zen Browser), class:^(youtube)$ windowrule = opaque, initialTitle:(Zen Browser), class:^(twitch)$ +# crunchyroll opaque +windowrule = opaque, class:(Crunchyroll) + # https://wiki.hyprland.org/Configuring/Variables/#general general { gaps_in = 1 diff --git a/scripts/bar b/scripts/bar index dba4e3f..9c1f5d7 100755 --- a/scripts/bar +++ b/scripts/bar @@ -13,53 +13,39 @@ command_exists() { command -v "$@" >/dev/null 2>&1 } -# fallback() { -# if command_exists hyprpanel; then -# pkill hyprpanel -# handle_error $? "pkill hyprpanel" -# hyprpanel & -# handle_error $? "hyprpanel" -# elif command_exists gBar; then -# pkill gBar -# handle_error $? "pkill gBar" -# gBar bar 0 & -# handle_error $? "gBar bar 0" -# elif command_exists waybar; then -# pkill waybar -# handle_error $? "pkill waybar" -# waybar & -# handle_error $? "waybar" -# else -# log_notify "critical" "Error" "No compatible bar found" -# exit 1 -# fi -# } +proc-kill-if() { + if pgrep "$1"; then + pkill "$1" + fi +} barsetup() { local bar="${1:-quickshell}" - case "$bar" in - hyprpanel) - pkill hyprpanel - hyprpanel & - ;; - gBar) - pkill gBar - gBar bar 0 & - ;; - waybar) - pkill waybar - waybar & - ;; - quickshell) - pkill qs - qs & - ;; - *) - pkill $bar - $bar & - ;; - esac + proc-kill-if "$bar" + + # case "$bar" in + # hyprpanel) + # pkill hyprpanel + # hyprpanel & + # ;; + # gBar) + # pkill gBar + # gBar bar 0 & + # ;; + # waybar) + # pkill waybar + # waybar & + # ;; + # quickshell) + # pkill qs + # qs & + # ;; + # *) + # pkill $bar + # $bar & + # ;; + # esac } if barsetup "$@"; then diff --git a/scripts/init b/scripts/init index 815e5be..eefdc4e 100755 --- a/scripts/init +++ b/scripts/init @@ -16,7 +16,7 @@ kill-all() { done } -SCRIPTS="$HOME/.config/hypr/.scripts" +SCRIPTS="$HOME/.config/hypr/scripts" # Logging helper log_notify() { @@ -53,16 +53,14 @@ setup-desktop() { case $module in copyq) - # pkill copyq 2>/dev/null - copyq --start-server - # sleep 1 - # if ! pgrep -x copyq >/dev/null; then - # # log_notify "critical" "ERROR" "CopyQ failed to start. Retrying..." - # copyq --start-server - # fi + if ! pgrep copyq; then + copyq --start-server + fi ;; lxappearance) - lxappearance >/dev/null 2>&1 & + if ! pgrep lxappearance; then + lxappearance >/dev/null 2>&1 & + fi ;; 'nwg-look') nwg-look -a >/dev/null 2>&1 & @@ -75,8 +73,7 @@ setup-desktop() { # fi # ;; redshift) - pkill redshift 2>/dev/null - bash -c "$SCRIPTS/redshift.sh" + . "$SCRIPTS/redshift.sh" ;; wob) local fifo="/tmp/$HYPRLAND_INSTANCE_SIGNATURE.wob" @@ -91,16 +88,16 @@ setup-desktop() { # Start polkit authentication agent init-polkit() { - agents=" - /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 - /usr/lib/polkit-kde-authentication-agent-1 - /usr/libexec/polkit-gnome-authentication-agent-1 - /usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1 - /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 - /usr/lib/polkit-1/polkit-agent-helper-1 - " + agents=( + "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1" + "/usr/lib/polkit-kde-authentication-agent-1" + "/usr/libexec/polkit-gnome-authentication-agent-1" + "/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1" + "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1" + "/usr/lib/polkit-1/polkit-agent-helper-1" + ) - for agent in $agents; do + for agent in "${agents[@]}"; do if [ -x "$agent" ]; then log_notify "normal" "INFO" "Starting Polkit agent: $(basename "$agent")" "$agent" & diff --git a/scripts/refresh b/scripts/refresh index 7cc5538..eef67e6 100755 --- a/scripts/refresh +++ b/scripts/refresh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ─< scriptdir declaration >────────────────────────────────────────────────────────────── -SCRIPTS="$HOME/.config/hypr/.scripts" +SCRIPTS="$HOME/.config/hypr/scripts" # ─< Check if the given command exists silently >───────────────────────────────────────── command_exists() { @@ -20,67 +20,9 @@ _kill_() { } _redshift() { - . $SCRIPTS/redshift.sh && notify-send -u low "󰴅" "Redshift active" + . "$SCRIPTS/redshift.sh" } -# ─< 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" diff --git a/scripts/wallpaper b/scripts/wallpaper index 99984c7..c281ba4 100755 --- a/scripts/wallpaper +++ b/scripts/wallpaper @@ -32,12 +32,29 @@ init() { fi } +get-wall-dir() { + local dirs=() + + dirs=( + "$HOME/.wallpapers" + "$HOME/.wallpaper" + ) + + for d in "${dirs[@]}"; do + if [ -d "$d" ]; then + echo "$d" + break + fi + done +} + randomSwww() { : "${SWWW_EXCLUDED_DIRS:=Anime,Colorful,Gaming,Gifs,Logos,Nordic,Windoof}" # if [ -z "$1" ]; then # ─< random wallpaper selection >───────────────────────────────────────────────────────── - local wall_dir="$HOME/.wallpaper" + # local wall_dir="$HOME/.wallpaper" + local wall_dir="$(get-wall-dir)" # ─< Create an array of directories to exclude >────────────────────────────────────────── IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS" @@ -57,6 +74,7 @@ randomSwww() { # local pic=$(eval "$find_cmd" | shuf -n 1) # Alternative approach using shopt shopt -s globstar nullglob + local pics=() for pic in "$wall_dir"/**/*.{png,jpg,jpeg,gif}; do # Skip excluded directories @@ -118,6 +136,17 @@ randomSwww() { # fi } +swww-path() { + # ─< executing swww with the random $pic >──────────────────────────────────────────────── + if swww img "$1" --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"; then + notify-send "󰸉 " "Changed wallpaper to ${pic##*/}" + notify-send " " "Not sourcing from: $SWWW_EXCLUDED_DIRS" + else + notify-send "ERROR" "Failed to set wallpaper: $pic" + return 1 + fi +} + # Main logic if [ -z "$1" ]; then init @@ -131,7 +160,11 @@ if [ -z "$1" ]; then # exit 1 # fi elif [ "$1" == "random" ]; then - randomSwww + if ! randomSwww; then + if ! pgrep swww; then + swww-daemon && randomSwww + fi + fi # Use a random wallpaper # wall_dir="$HOME/.wallpaper" # IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS" @@ -153,16 +186,10 @@ elif [ "$1" == "random" ]; then else # Use the specified path if [ -f "$1" ]; then - # ─< executing swww with the random $pic >──────────────────────────────────────────────── - if swww img "$1" --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION"; then - notify-send "󰸉 " "Changed wallpaper to ${pic##*/}" - notify-send " " "Not sourcing from: $SWWW_EXCLUDED_DIRS" - else - notify-send "ERROR" "Failed to set wallpaper: $pic" - return 1 + if ! swww-path "$1"; then + if ! pgrep swww; then + swww-daemon && swww-path "$1" + fi fi - else - log_notify "critical" "Error" "File not found: $1" - exit 1 fi fi