From b015c17ccac447a1b091fa1facaadb66fe7ed739 Mon Sep 17 00:00:00 2001 From: Stephan Date: Sun, 23 Aug 2026 14:31:43 -0700 Subject: [PATCH] cleanup of scripts --- hypr/scripts/monitor_setup.sh | 103 --------------------------------- hypr/scripts/monitor_setup2.sh | 94 ------------------------------ hypr/scripts/update-sys.sh | 13 +++-- 3 files changed, 7 insertions(+), 203 deletions(-) delete mode 100755 hypr/scripts/monitor_setup.sh delete mode 100755 hypr/scripts/monitor_setup2.sh diff --git a/hypr/scripts/monitor_setup.sh b/hypr/scripts/monitor_setup.sh deleted file mode 100755 index c58fc55..0000000 --- a/hypr/scripts/monitor_setup.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash -# ~/.config/hypr/scripts/monitor_setup.sh - -notify-send -t 3000 "Monitor Setup" "Detecting display configuration..." - -LAPTOP="eDP-1" -LID_STATE=$(grep -q "open" /proc/acpi/button/lid/LID/state && echo "open" || echo "closed") -MONITORS=$(hyprctl monitors -j) - -if [[ $(echo "$MONITORS" | jq 'length') -eq 0 ]]; then - notify-send "Monitor Error" "No monitors detected." - exit 1 -fi - -EXTERNAL=$(echo "$MONITORS" | jq -r '.[] | select(.name != "'$LAPTOP'") | .name' | head -1) - -get_capped_res() { - local monitor=$1 - local modes=$(echo "$MONITORS" | jq -r ".[] | select(.name == \"$monitor\") | .availableModes[]") - - if [[ -z "$modes" ]]; then - echo "preferred" - return - fi - - local max_pixels=0 - local max_refresh=0 - local best_mode="preferred" - - while IFS= read -r mode; do - local width=$(echo "$mode" | awk -F'@' '{print $1}' | awk -F'x' '{print $1}') - local height=$(echo "$mode" | awk -F'@' '{print $1}' | awk -F'x' '{print $2}') - local refresh=$(echo "$mode" | awk -F'@' '{print $2}' | sed 's/Hz//') - - if (( $(echo "$refresh > 120.1" | bc -l) )); then - continue - fi - - local pixels=$((width * height)) - - if [[ $pixels -gt $max_pixels || ($pixels -eq $max_pixels && $(echo "$refresh > $max_refresh" | bc -l) -eq 1) ]]; then - max_pixels=$pixels - max_refresh=$refresh - best_mode="${width}x${height}@${refresh}" - fi - done <<< "$modes" - - echo "$best_mode" -} - -EXT_RES=$(get_capped_res "$EXTERNAL") -LAPTOP_RES=$(get_capped_res "$LAPTOP") - -# Case 1: Laptop Only -if [ -z "$EXTERNAL" ]; then - notify-send -t 7000 "Monitor Setup" "Laptop Mode: $LAPTOP_RES" - hyprctl keyword monitor "$LAPTOP,$LAPTOP_RES,auto,1" - - for ws in {1..5}; do - hyprctl dispatch workspace "$ws" # Ensure workspace exists - hyprctl keyword "workspace $ws,monitor:$LAPTOP" - done - exit 0 -fi - -# Case 2: External + Open Lid -if [ "$LID_STATE" = "open" ]; then - notify-send -t 7000 "Monitor Setup" "Dual Mode\nExternal: $EXT_RES (VRR On)" - - hyprctl keyword monitor "$LAPTOP,$LAPTOP_RES,0x0,1" - hyprctl keyword monitor "$EXTERNAL,$EXT_RES,auto,1,vrr,1" - - sleep 1 - - # Workspace 1 & 2 to Big Screen - for ws in 1 2; do - hyprctl dispatch workspace "$ws" - hyprctl keyword "workspace $ws,monitor:$EXTERNAL" - hyprctl dispatch moveworkspacetomonitor "$ws" "$EXTERNAL" - done - # Workspace 3 to Laptop - hyprctl dispatch workspace 3 - hyprctl keyword "workspace 3,monitor:$LAPTOP" - hyprctl dispatch moveworkspacetomonitor 3 "$LAPTOP" - -# Case 3: External Only (Clamshell) -else - notify-send -t 3000 "Monitor Setup" "Clamshell Mode\nExternal: $EXT_RES (VRR On)" - - hyprctl dispatch dpms off "$LAPTOP" - hyprctl keyword monitor "$LAPTOP,disable" - hyprctl keyword monitor "$EXTERNAL,$EXT_RES,0x0,1,vrr,1" - - sleep 1 - - for ws in {1..5}; do - hyprctl dispatch workspace "$ws" - hyprctl keyword "workspace $ws,monitor:$EXTERNAL" - hyprctl dispatch moveworkspacetomonitor "$ws" "$EXTERNAL" - done -fi - -hyprctl dispatch workspace 1 diff --git a/hypr/scripts/monitor_setup2.sh b/hypr/scripts/monitor_setup2.sh deleted file mode 100755 index 52a9323..0000000 --- a/hypr/scripts/monitor_setup2.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -# ~/.config/hypr/scripts/monitor_setup.sh - -notify-send -t 3000 "Monitor Setup" "Detecting display configuration..." - -LAPTOP="eDP-1" -LID_STATE=$(grep -q "open" /proc/acpi/button/lid/LID/state && echo "open" || echo "closed") -MONITORS=$(hyprctl monitors -j) - -if [[ $(echo "$MONITORS" | jq 'length') -eq 0 ]]; then - notify-send "Monitor Error" "No monitors detected." - exit 1 -fi - -EXTERNAL=$(echo "$MONITORS" | jq -r '.[] | select(.name != "'$LAPTOP'") | .name' | head -1) - -get_capped_res() { - local monitor=$1 - local modes=$(echo "$MONITORS" | jq -r ".[] | select(.name == \"$monitor\") | .availableModes[]?") - - if [[ -z "$modes" ]]; then - echo "preferred" - return - fi - - local max_pixels=0 - local max_refresh=0 - local best_mode="preferred" - - while IFS= read -r mode; do - local width=$(echo "$mode" | awk -F'@' '{print $1}' | awk -F'x' '{print $1}') - local height=$(echo "$mode" | awk -F'@' '{print $1}' | awk -F'x' '{print $2}') - local refresh=$(echo "$mode" | awk -F'@' '{print $2}' | sed 's/Hz//') - - if (( $(echo "$refresh > 120.1" | bc -l) )); then - continue - fi - - local pixels=$((width * height)) - - if [[ $pixels -gt $max_pixels || ($pixels -eq $max_pixels && $(echo "$refresh > $max_refresh" | bc -l) -eq 1) ]]; then - max_pixels=$pixels - max_refresh=$refresh - best_mode="${width}x${height}@${refresh}" - fi - done <<< "$modes" - - echo "$best_mode" -} - -EXT_RES=$(get_capped_res "$EXTERNAL") -LAPTOP_RES=$(get_capped_res "$LAPTOP") - -# Case 1: Laptop Only -if [ -z "$EXTERNAL" ]; then - notify-send -t 7000 "Monitor Setup" "Laptop Mode: $LAPTOP_RES" - - hyprctl --batch \ - "eval 'hl.monitor({ output = \"$LAPTOP\", mode = \"$LAPTOP_RES\", position = \"auto\", scale = 1 })' ; \ - eval 'hl.dsp.workspace_move_to_monitor(1, \"$LAPTOP\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(2, \"$LAPTOP\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(3, \"$LAPTOP\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(4, \"$LAPTOP\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(5, \"$LAPTOP\")'" - exit 0 -fi - -# Case 2: External + Open Lid -if [ "$LID_STATE" = "open" ]; then - notify-send -t 7000 "Monitor Setup" "Dual Mode\nExternal: $EXT_RES" - - hyprctl --batch \ - "eval 'hl.monitor({ output = \"$LAPTOP\", mode = \"$LAPTOP_RES\", position = \"0x0\", scale = 1 })' ; \ - eval 'hl.monitor({ output = \"$EXTERNAL\", mode = \"$EXT_RES\", position = \"auto\", scale = 1 })' ; \ - eval 'hl.dsp.workspace_move_to_monitor(1, \"$EXTERNAL\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(2, \"$EXTERNAL\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(3, \"$LAPTOP\")'" - -# Case 3: External Only (Clamshell) -else - notify-send -t 3000 "Monitor Setup" "Clamshell Mode\nExternal: $EXT_RES" - - hyprctl --batch \ - "eval 'hl.monitor({ output = \"$EXTERNAL\", mode = \"$EXT_RES\", position = \"0x0\", scale = 1 })' ; \ - eval 'hl.dsp.dpms(\"off\", \"$LAPTOP\")' ; - eval 'hl.monitor({ output = \"$LAPTOP\", disabled = true })' ; \ - eval 'hl.dsp.workspace_move_to_monitor(1, \"$EXTERNAL\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(2, \"$EXTERNAL\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(3, \"$EXTERNAL\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(4, \"$EXTERNAL\")' ; \ - eval 'hl.dsp.workspace_move_to_monitor(5, \"$EXTERNAL\")'" -fi - -hyprctl eval 'hl.dsp.focus({ workspace = "1" })' diff --git a/hypr/scripts/update-sys.sh b/hypr/scripts/update-sys.sh index 0cffdb8..3680dab 100755 --- a/hypr/scripts/update-sys.sh +++ b/hypr/scripts/update-sys.sh @@ -2,22 +2,23 @@ # If 'up' argument is passed, run update in terminal if [ "$1" == "up" ]; then - ghostty -e bash -c "yay -Syu; echo 'Done. Press Enter.'; read" + ghostty -e bash -c "yay -Syu && flatpak update; echo 'Done. Press Enter.'; read" exit 0 fi # Otherwise, do a quick parallel check notify-send "Checking Updates..." -t 1500 -# Check Pacman and AUR in parallel -pc_count=$(checkupdates 2>/dev/null | wc -l &) -aur_count=$(yay -Qua 2>/dev/null | wc -l &) +# Check Pacman, AUR, and Flatpaks in parallel +pc_count=$(checkupdates 2>/dev/null | wc -l) & +aur_count=$(yay -Qua 2>/dev/null | wc -l) & +fp_count=$(flatpak remote-ls --updates 2>/dev/null | wc -l) & wait -total=$((pc_count + aur_count)) +total=$((pc_count + aur_count + fp_count)) if [ "$total" -eq 0 ]; then notify-send "System Up to Date" "No packages to update." -i checkbox-checked-symbolic else - notify-send "Updates Available" "󰚰 Total: $total\nRepo: $pc_count | AUR: $aur_count\n\nPress SUPER+U to update." -i software-update-available-symbolic + notify-send "Updates Available" "󰚰 Total: $total\nRepo: $pc_count | AUR: $aur_count | Flatpak: $fp_count\n\nPress SUPER+U to update." -i software-update-available-symbolic fi