From 63b45e2e0bb24215e80482a8a05a422449782f9d Mon Sep 17 00:00:00 2001 From: krolxon Date: Wed, 7 Jan 2026 23:26:08 +0530 Subject: readme.md --- .local/bin/hypr/hypr_screen_rotate.sh | 114 ++++++++++++++++++++++++++++++++++ .local/bin/hypr/screen_rotate.sh | 114 ---------------------------------- README.md | 6 ++ 3 files changed, 120 insertions(+), 114 deletions(-) create mode 100755 .local/bin/hypr/hypr_screen_rotate.sh delete mode 100755 .local/bin/hypr/screen_rotate.sh diff --git a/.local/bin/hypr/hypr_screen_rotate.sh b/.local/bin/hypr/hypr_screen_rotate.sh new file mode 100755 index 0000000..5fdf062 --- /dev/null +++ b/.local/bin/hypr/hypr_screen_rotate.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env bash +# Script taken from and modified little bit from: +# https://github.com/dusklinux/dusky/blob/f8a28f425743e478cddefc327e6e554dfcf9521d/user_scripts/hypr/screen_rotate.sh + +# 1. Strict Mode & Safety (Bash 5+ Standards) +# ------------------------------------------------------------------------------ +set -euo pipefail +IFS=$'\n\t' + +# 2. Global Constants (ANSI-C Quoting for "Elite" Color Handling) +# ------------------------------------------------------------------------------ +readonly C_RED=$'\e[31m' +readonly C_GREEN=$'\e[32m' +readonly C_YELLOW=$'\e[33m' +readonly C_BLUE=$'\e[34m' +readonly C_BOLD=$'\e[1m' +readonly C_RESET=$'\e[0m' + +# cleanup_trap: Ensures clean exit codes are respected. +cleanup_trap() { + local exit_code=$? + if [[ $exit_code -ne 0 ]]; then + printf "%s[ERROR]%s Script aborted unexpectedly (Exit Code: %d).\n" \ + "$C_RED" "$C_RESET" "$exit_code" >&2 + fi +} +trap cleanup_trap EXIT + +# 3. Environment & Privilege Checks +# ------------------------------------------------------------------------------ +# Dependency Check: We need 'jq' for JSON parsing. +if ! command -v jq &> /dev/null; then + printf "%s[ERROR]%s 'jq' is missing. Install it with: sudo pacman -S jq\n" \ + "$C_RED" "$C_RESET" >&2 + exit 1 +fi + +# Root Check: Hyprland IPC fails if executed as root/sudo due to socket ownership. +if [[ $EUID -eq 0 ]]; then + printf "%s[ERROR]%s Root detected. Please run this as your normal user to access the Hyprland socket.\n" \ + "$C_RED" "$C_RESET" >&2 + exit 1 +fi + +# 4. Argument Parsing (+90 or -90) +# ------------------------------------------------------------------------------ +DIRECTION=0 + +if [[ $# -ne 1 ]]; then + printf "%s[INFO]%s Usage: %s [+90|-90]\n" \ + "$C_YELLOW" "$C_RESET" "${0##*/}" + exit 1 +fi + +case "$1" in + "+90") DIRECTION=1 ;; # Clockwise + "-90") DIRECTION=-1 ;; # Counter-Clockwise + *) + printf "%s[ERROR]%s Invalid flag '%s'. Use +90 or -90.\n" \ + "$C_RED" "$C_RESET" "$1" >&2 + exit 1 + ;; +esac + +# 5. Hardware Detection (Smart Query) +# ------------------------------------------------------------------------------ +# We fetch the entire JSON blob once to minimize IPC calls (Performance). +# We select the current focused monitor +MON_STATE=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true)') + +# Extract precise values using jq +NAME=$(printf "%s" "$MON_STATE" | jq -r '.name') +SCALE=$(printf "%s" "$MON_STATE" | jq -r '.scale') +CURRENT_TRANSFORM=$(printf "%s" "$MON_STATE" | jq -r '.transform') + +# Validation: Ensure we actually found a monitor +if [[ -z "$NAME" || "$NAME" == "null" ]]; then + printf "%s[ERROR]%s No active monitors detected via Hyprland IPC.\n" \ + "$C_RED" "$C_RESET" >&2 + exit 1 +fi + +# 6. Transformation Logic (Modulo Arithmetic) +# ------------------------------------------------------------------------------ +# Hyprland Transforms: 0=Normal, 1=90, 2=180, 3=270 +# The '+ 4' ensures we handle negative wraparounds correctly in Bash logic. +NEW_TRANSFORM=$(( (CURRENT_TRANSFORM + DIRECTION + 4) % 4 )) + +# 7. Execution (State overwrite) +# ------------------------------------------------------------------------------ +# We use 'preferred' and 'auto' to remain robust against resolution changes, +# but we STRICTLY inject the detected $SCALE to prevent UI scaling issues. + +printf "%s[INFO]%s Rotating %s%s%s (Scale: %s): %d -> %d\n" \ + "$C_BLUE" "$C_RESET" "$C_BOLD" "$NAME" "$C_RESET" "$SCALE" "$CURRENT_TRANSFORM" "$NEW_TRANSFORM" + +# Apply the new configuration immediately via IPC +if hyprctl keyword monitor "${NAME}, preferred, auto, ${SCALE}, transform, ${NEW_TRANSFORM}" > /dev/null; then + printf "%s[SUCCESS]%s Rotation applied successfully.\n" \ + "$C_GREEN" "$C_RESET" + + # Notify user visually if notify-send is available (optional UX improvement) + if command -v notify-send &> /dev/null; then + notify-send -a "System" "Display Rotated" "Monitor: $NAME\nTransform: $NEW_TRANSFORM" -h string:x-canonical-private-synchronous:display-rotate + fi +else + printf "%s[ERROR]%s Failed to apply Hyprland keyword.\n" \ + "$C_RED" "$C_RESET" >&2 + exit 1 +fi + +# Clean exit +trap - EXIT +exit 0 diff --git a/.local/bin/hypr/screen_rotate.sh b/.local/bin/hypr/screen_rotate.sh deleted file mode 100755 index 5fdf062..0000000 --- a/.local/bin/hypr/screen_rotate.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash -# Script taken from and modified little bit from: -# https://github.com/dusklinux/dusky/blob/f8a28f425743e478cddefc327e6e554dfcf9521d/user_scripts/hypr/screen_rotate.sh - -# 1. Strict Mode & Safety (Bash 5+ Standards) -# ------------------------------------------------------------------------------ -set -euo pipefail -IFS=$'\n\t' - -# 2. Global Constants (ANSI-C Quoting for "Elite" Color Handling) -# ------------------------------------------------------------------------------ -readonly C_RED=$'\e[31m' -readonly C_GREEN=$'\e[32m' -readonly C_YELLOW=$'\e[33m' -readonly C_BLUE=$'\e[34m' -readonly C_BOLD=$'\e[1m' -readonly C_RESET=$'\e[0m' - -# cleanup_trap: Ensures clean exit codes are respected. -cleanup_trap() { - local exit_code=$? - if [[ $exit_code -ne 0 ]]; then - printf "%s[ERROR]%s Script aborted unexpectedly (Exit Code: %d).\n" \ - "$C_RED" "$C_RESET" "$exit_code" >&2 - fi -} -trap cleanup_trap EXIT - -# 3. Environment & Privilege Checks -# ------------------------------------------------------------------------------ -# Dependency Check: We need 'jq' for JSON parsing. -if ! command -v jq &> /dev/null; then - printf "%s[ERROR]%s 'jq' is missing. Install it with: sudo pacman -S jq\n" \ - "$C_RED" "$C_RESET" >&2 - exit 1 -fi - -# Root Check: Hyprland IPC fails if executed as root/sudo due to socket ownership. -if [[ $EUID -eq 0 ]]; then - printf "%s[ERROR]%s Root detected. Please run this as your normal user to access the Hyprland socket.\n" \ - "$C_RED" "$C_RESET" >&2 - exit 1 -fi - -# 4. Argument Parsing (+90 or -90) -# ------------------------------------------------------------------------------ -DIRECTION=0 - -if [[ $# -ne 1 ]]; then - printf "%s[INFO]%s Usage: %s [+90|-90]\n" \ - "$C_YELLOW" "$C_RESET" "${0##*/}" - exit 1 -fi - -case "$1" in - "+90") DIRECTION=1 ;; # Clockwise - "-90") DIRECTION=-1 ;; # Counter-Clockwise - *) - printf "%s[ERROR]%s Invalid flag '%s'. Use +90 or -90.\n" \ - "$C_RED" "$C_RESET" "$1" >&2 - exit 1 - ;; -esac - -# 5. Hardware Detection (Smart Query) -# ------------------------------------------------------------------------------ -# We fetch the entire JSON blob once to minimize IPC calls (Performance). -# We select the current focused monitor -MON_STATE=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true)') - -# Extract precise values using jq -NAME=$(printf "%s" "$MON_STATE" | jq -r '.name') -SCALE=$(printf "%s" "$MON_STATE" | jq -r '.scale') -CURRENT_TRANSFORM=$(printf "%s" "$MON_STATE" | jq -r '.transform') - -# Validation: Ensure we actually found a monitor -if [[ -z "$NAME" || "$NAME" == "null" ]]; then - printf "%s[ERROR]%s No active monitors detected via Hyprland IPC.\n" \ - "$C_RED" "$C_RESET" >&2 - exit 1 -fi - -# 6. Transformation Logic (Modulo Arithmetic) -# ------------------------------------------------------------------------------ -# Hyprland Transforms: 0=Normal, 1=90, 2=180, 3=270 -# The '+ 4' ensures we handle negative wraparounds correctly in Bash logic. -NEW_TRANSFORM=$(( (CURRENT_TRANSFORM + DIRECTION + 4) % 4 )) - -# 7. Execution (State overwrite) -# ------------------------------------------------------------------------------ -# We use 'preferred' and 'auto' to remain robust against resolution changes, -# but we STRICTLY inject the detected $SCALE to prevent UI scaling issues. - -printf "%s[INFO]%s Rotating %s%s%s (Scale: %s): %d -> %d\n" \ - "$C_BLUE" "$C_RESET" "$C_BOLD" "$NAME" "$C_RESET" "$SCALE" "$CURRENT_TRANSFORM" "$NEW_TRANSFORM" - -# Apply the new configuration immediately via IPC -if hyprctl keyword monitor "${NAME}, preferred, auto, ${SCALE}, transform, ${NEW_TRANSFORM}" > /dev/null; then - printf "%s[SUCCESS]%s Rotation applied successfully.\n" \ - "$C_GREEN" "$C_RESET" - - # Notify user visually if notify-send is available (optional UX improvement) - if command -v notify-send &> /dev/null; then - notify-send -a "System" "Display Rotated" "Monitor: $NAME\nTransform: $NEW_TRANSFORM" -h string:x-canonical-private-synchronous:display-rotate - fi -else - printf "%s[ERROR]%s Failed to apply Hyprland keyword.\n" \ - "$C_RED" "$C_RESET" >&2 - exit 1 -fi - -# Clean exit -trap - EXIT -exit 0 diff --git a/README.md b/README.md index 3dfef11..044ee64 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,16 @@ 2. Gum (For pretty prompts) 3. Base arch install +```bash +sudo pacman -S git gum +``` + ## Usage ```bash cd $HOME git clone https://github.com/krolyxon/dotfiles.git ~/.dotfiles cd ~/.dotfiles ./install.sh +# Installation with no confirmation prompts +./insall.sh --yes ``` -- cgit v1.2.3