modularize hyprland configs, add zoom, scale, rotate script and keybinds

This commit is contained in:
krolxon 2026-01-07 13:26:51 +05:30
parent d1a4318b2f
commit 627d496fb6
9 changed files with 386 additions and 260 deletions

View File

@ -1,18 +1,13 @@
source = $HOME/.cache/wal/colors-hyprland.conf source = $HOME/.cache/wal/colors-hyprland.conf
autogenerated = 0 autogenerated = 0
################### # 1. PROGRAMS
### MY PROGRAMS ###
###################
$terminal = foot $terminal = foot
$menu = fuzzel $menu = fuzzel
$browser = zen-browser $browser = zen-browser
$passwordmanager = keepmenu $passwordmanager = keepmenu
# 2. AUTOSTART
#################
### AUTOSTART ###
#################
exec-once = (hyprpm reload -n & kanshi & waybar & swaync & gammastep & hypridle) exec-once = (hyprpm reload -n & kanshi & waybar & swaync & gammastep & hypridle)
exec-once = ~/.local/bin/setwall -n exec-once = ~/.local/bin/setwall -n
exec-once = systemctl --user start hyprpolkitagent exec-once = systemctl --user start hyprpolkitagent
@ -24,34 +19,11 @@ plugin {
} }
} }
############################# # 3. ENVIRONMENT VARIABLES
### ENVIRONMENT VARIABLES ### source = ~/.config/hypr/source/environment_variables.conf
#############################
# See https://wiki.hypr.land/Configuring/Environment-variables/
env = HYPRSHOT_DIR,/home/krolyxon/pix/ss/
env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24
# env = GTK_THEME,Tokyonight-Dark
# XDG Specifications
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland
# Toolkit # 4. PLUGIN SETTINGS
env = GDK_BACKEND,wayland,x11,* # GTK: Use Wayland if available; if not, try X11 and then any other GDK backend.
env = QT_QPA_PLATFORM,wayland;xcb # Qt: Use Wayland if available, fall back to X11 if not
env = SDL_VIDEODRIVER,Wayland # Run SDL2 applications on Wayland. Remove or set to x11 if games that provide older versions of SDL cause compatibility issues
env = CLUTTER_BACKEND,wayland # Clutter applications to try and use the Wayland backend
# Nvidia
# env = GBM_BACKEND,nvidia-drm
# env = __GLX_VENDOR_LIBRARY_NAME,nvidia
# env = LIBVA_DRIVER_NAME,nvidia
#######################
### PLUGIN SETTINGS ###
#######################
plugin { plugin {
split-monitor-workspaces { split-monitor-workspaces {
count = 10 count = 10
@ -61,236 +33,19 @@ plugin {
} }
} }
# 5. PERMISSIONS
source = ~/.config/hypr/source/permissions.conf
################### # 6. LOOK AND FEEL
### PERMISSIONS ### source = ~/.config/hypr/source/appearance.conf
###################
ecosystem {
enforce_permissions = 1
}
permission = /usr/(bin|local/bin)/grim, screencopy, allow # 7. INPUT
permission = /usr/(bin|local/bin)/hyprlock, screencopy, allow source = ~/.config/hypr/source/input.conf
permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
permission = /usr/(bin|local/bin)/hyprpm, plugin, allow
permission = ${lib.escapeRegex (lib.getExe config.programs.hyprlock.package)}, screencopy, allow
# 8. KEYBINDINGS
source = ~/.config/hypr/source/keybinds.conf
#####################
### LOOK AND FEEL ###
#####################
general {
gaps_in = 2
gaps_out = 2
border_size = 2
resize_on_border = false
allow_tearing = false
# col.active_border = $color14 $color0 $color0 $color14 45deg
col.active_border = $color14 $color14 $color14 $color14 45deg
col.inactive_border = $color0 $color0 $color0 $color0 45deg
layout = master
}
decoration {
# rounding = 8
blur {
enabled = false
size = 3
passes = 1
}
# blur {
# enabled = true
# size = 3
# passes = 3
# new_optimizations = true
# vibrancy = 0.1696
# ignore_opacity = true
# }
}
animations {
enabled = false
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 2, myBezier
animation = windowsOut, 1, 2, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 1, default
}
# Ref https://wiki.hypr.land/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that.
# workspace = w[tv1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0
# windowrule = bordersize 0, floating:0, onworkspace:w[tv1]
# windowrule = rounding 0, floating:0, onworkspace:w[tv1]
# windowrule = bordersize 0, floating:0, onworkspace:f[1]
# windowrule = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hypr.land/Configuring/Dwindle-Layout/ for more
dwindle {
pseudotile = true# Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true # You probably want this
}
# See https://wiki.hypr.land/Configuring/Master-Layout/ for more
master {
new_status = master
new_on_top = true
}
# https://wiki.hypr.land/Configuring/Variables/#misc
misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = true# If true disables the random hyprland logo / anime girl background. :(
disable_splash_rendering = true
mouse_move_enables_dpms = true
key_press_enables_dpms = true
vrr = 0 # Disable adaptive sync
}
#############
### INPUT ###
#############
# https://wiki.hypr.land/Configuring/Variables/#input
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
touchpad {
natural_scroll = false
}
repeat_delay = 300
repeat_rate = 50
}
# Example per-device config
# See https://wiki.hypr.land/Configuring/Keywords/#per-device-input-configs for more
device {
name = epic-mouse-v1
sensitivity = -0.5
}
###################
### KEYBINDINGS ###
###################
# See https://wiki.hypr.land/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier
# Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more
bind = $mainMod, Return, exec, $terminal
bind = $mainMod SHIFT, X, killactive,
bind = $mainMod SHIFT, Q, exit,
bind = $mainMod, F, Fullscreen
bind = $mainMod SHIFT, F, Fullscreen, 1
bind = $mainMod SHIFT, R, togglefloating,
bind = $mainMod, R, exec, $menu
bind = $mainMod SHIFT, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
binde = $mainMod, tab, cyclenext, prev
bind = $mainMod, b, exec, killall waybar || waybar
bind = $mainMod, grave, exec, fuzzelunicode
bind = $mainMod, escape, exec, sysact
# Applications
bind = $mainMod, W, exec, $browser
bind = $mainMod SHIFT, p, exec, $passwordmanager -C
bind = ,PRINT, exec, screenshot
# Music Controls
bind = $mainMod, m, exec, $terminal -e zsh -i -c "ncmpcpp"
bind = $mainMod, p, exec, mpc toggle
binde = $mainMod, period, exec, mpc seek +10
binde = $mainMod, comma, exec, mpc seek -10
bind = $mainMod SHIFT, period, exec, mpc next
bind = $mainMod SHIFT, comma, exec, mpc prev
# Swap current focused window with master
bind = $mainMod, space, layoutmsg, swapwithmaster
# Resize windows with h/j/k/l
binde = $mainMod, h, resizeactive, -30 0
binde = $mainMod, l, resizeactive, 30 0
binde = $mainMod, k, resizeactive, 0 -30
binde = $mainMod, j, resizeactive, 0 30
# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, split-workspace, 1
bind = $mainMod, 2, split-workspace, 2
bind = $mainMod, 3, split-workspace, 3
bind = $mainMod, 4, split-workspace, 4
bind = $mainMod, 5, split-workspace, 5
bind = $mainMod, 6, split-workspace, 6
bind = $mainMod, 7, split-workspace, 7
bind = $mainMod, 8, split-workspace, 8
bind = $mainMod, 9, split-workspace, 9
bind = $mainMod, 0, split-workspace, 10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, split-movetoworkspacesilent, 1
bind = $mainMod SHIFT, 2, split-movetoworkspacesilent, 2
bind = $mainMod SHIFT, 3, split-movetoworkspacesilent, 3
bind = $mainMod SHIFT, 4, split-movetoworkspacesilent, 4
bind = $mainMod SHIFT, 5, split-movetoworkspacesilent, 5
bind = $mainMod SHIFT, 6, split-movetoworkspacesilent, 6
bind = $mainMod SHIFT, 7, split-movetoworkspacesilent, 7
bind = $mainMod SHIFT, 8, split-movetoworkspacesilent, 8
bind = $mainMod SHIFT, 9, split-movetoworkspacesilent, 9
bind = $mainMod SHIFT, 0, split-movetoworkspacesilent, 10
# Example special workspace (scratchpad)
bind = $mainMod, S, togglespecialworkspace, magic
bind = $mainMod SHIFT, S, movetoworkspace, special:magic
# Have scratchpad like DWM
workspace = special:h, on-created-empty: $terminal
bind = $mainMod SHIFT, Return, togglespecialworkspace, h
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
# Laptop multimedia keys for volume and LCD brightness
bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+
bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindel = , XF86MonBrightnessDown, exec, ~/.local/bin/brictl -
bindel = , XF86MonBrightnessUp, exec, ~/.local/bin/brictl +
# Requires playerctl
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPrev, exec, playerctl previous
############################## ##############################
### WINDOWS AND WORKSPACES ### ### WINDOWS AND WORKSPACES ###

View File

@ -0,0 +1,80 @@
general {
gaps_in = 2
gaps_out = 2
border_size = 2
resize_on_border = false
allow_tearing = false
# col.active_border = $color14 $color0 $color0 $color14 45deg
col.active_border = $color14 $color14 $color14 $color14 45deg
col.inactive_border = $color0 $color0 $color0 $color0 45deg
layout = master
}
decoration {
# rounding = 8
blur {
enabled = false
size = 3
passes = 1
}
# blur {
# enabled = true
# size = 3
# passes = 3
# new_optimizations = true
# vibrancy = 0.1696
# ignore_opacity = true
# }
}
animations {
enabled = false
bezier = myBezier, 0.05, 0.9, 0.1, 1.05
animation = windows, 1, 2, myBezier
animation = windowsOut, 1, 2, default, popin 80%
animation = border, 1, 10, default
animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 1, default
}
# Ref https://wiki.hypr.land/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only"
# uncomment all if you wish to use that.
# workspace = w[tv1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0
# windowrule = bordersize 0, floating:0, onworkspace:w[tv1]
# windowrule = rounding 0, floating:0, onworkspace:w[tv1]
# windowrule = bordersize 0, floating:0, onworkspace:f[1]
# windowrule = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hypr.land/Configuring/Dwindle-Layout/ for more
dwindle {
pseudotile = true# Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below
preserve_split = true # You probably want this
}
# See https://wiki.hypr.land/Configuring/Master-Layout/ for more
master {
new_status = master
new_on_top = true
}
# https://wiki.hypr.land/Configuring/Variables/#misc
misc {
force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers
disable_hyprland_logo = true# If true disables the random hyprland logo / anime girl background. :(
disable_splash_rendering = true
mouse_move_enables_dpms = true
key_press_enables_dpms = true
vrr = 0 # Disable adaptive sync
}

View File

@ -0,0 +1,22 @@
# See https://wiki.hypr.land/Configuring/Environment-variables/
env = HYPRSHOT_DIR,/home/krolyxon/pix/ss/
env = XCURSOR_SIZE,24
env = HYPRCURSOR_SIZE,24
# env = GTK_THEME,Tokyonight-Dark
# XDG Specifications
env = XDG_CURRENT_DESKTOP,Hyprland
env = XDG_SESSION_TYPE,wayland
env = XDG_SESSION_DESKTOP,Hyprland
# Toolkit
env = GDK_BACKEND,wayland,x11,* # GTK: Use Wayland if available; if not, try X11 and then any other GDK backend.
env = QT_QPA_PLATFORM,wayland;xcb # Qt: Use Wayland if available, fall back to X11 if not
env = SDL_VIDEODRIVER,Wayland # Run SDL2 applications on Wayland. Remove or set to x11 if games that provide older versions of SDL cause compatibility issues
env = CLUTTER_BACKEND,wayland # Clutter applications to try and use the Wayland backend
# Nvidia
# env = GBM_BACKEND,nvidia-drm
# env = __GLX_VENDOR_LIBRARY_NAME,nvidia
# env = LIBVA_DRIVER_NAME,nvidia

View File

@ -0,0 +1,27 @@
# https://wiki.hypr.land/Configuring/Variables/#input
input {
kb_layout = us
kb_variant =
kb_model =
kb_options =
kb_rules =
follow_mouse = 1
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
touchpad {
natural_scroll = false
}
repeat_delay = 300
repeat_rate = 50
}
# Example per-device config
# See https://wiki.hypr.land/Configuring/Keywords/#per-device-input-configs for more
device {
name = epic-mouse-v1
sensitivity = -0.5
}

View File

@ -0,0 +1,117 @@
###################
### KEYBINDINGS ###
###################
# See https://wiki.hypr.land/Configuring/Keywords/
$mainMod = SUPER # Sets "Windows" key as main modifier
# Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more
bind = $mainMod, Return, exec, $terminal
bind = $mainMod SHIFT, X, killactive,
bind = $mainMod SHIFT, Q, exit,
bind = $mainMod, F, Fullscreen
bind = $mainMod SHIFT, F, Fullscreen, 1
# bind = $mainMod SHIFT, R, togglefloating,
# Smart Float: Toggle float -> Resize to 90% -> Center
bind = $mainMod SHIFT, R, exec, if hyprctl -j activewindow | jq -e '.floating | not'; then hyprctl --batch "dispatch togglefloating; dispatch resizeactive exact 90% 90%; dispatch centerwindow"; else hyprctl dispatch togglefloating; fi
bind = $mainMod, R, exec, $menu
bind = $mainMod SHIFT, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
binde = $mainMod, tab, cyclenext, prev
bind = $mainMod, b, exec, killall waybar || waybar
bind = $mainMod, grave, exec, fuzzelunicode
bind = $mainMod, escape, exec, sysact
# Applications
bind = $mainMod, W, exec, $browser
bind = $mainMod SHIFT, p, exec, $passwordmanager -C
bind = ,PRINT, exec, screenshot
# Music Controls
bind = $mainMod, m, exec, $terminal -e zsh -i -c "ncmpcpp"
bind = $mainMod, p, exec, mpc toggle
binde = $mainMod, period, exec, mpc seek +10
binde = $mainMod, comma, exec, mpc seek -10
bind = $mainMod SHIFT, period, exec, mpc next
bind = $mainMod SHIFT, comma, exec, mpc prev
# Swap current focused window with master
bind = $mainMod, space, layoutmsg, swapwithmaster
# Resize windows with h/j/k/l
binde = $mainMod, h, resizeactive, -30 0
binde = $mainMod, l, resizeactive, 30 0
binde = $mainMod, k, resizeactive, 0 -30
binde = $mainMod, j, resizeactive, 0 30
# Switch workspaces with mainMod + [0-9]
bind = $mainMod, 1, split-workspace, 1
bind = $mainMod, 2, split-workspace, 2
bind = $mainMod, 3, split-workspace, 3
bind = $mainMod, 4, split-workspace, 4
bind = $mainMod, 5, split-workspace, 5
bind = $mainMod, 6, split-workspace, 6
bind = $mainMod, 7, split-workspace, 7
bind = $mainMod, 8, split-workspace, 8
bind = $mainMod, 9, split-workspace, 9
bind = $mainMod, 0, split-workspace, 10
# Move active window to a workspace with mainMod + SHIFT + [0-9]
bind = $mainMod SHIFT, 1, split-movetoworkspacesilent, 1
bind = $mainMod SHIFT, 2, split-movetoworkspacesilent, 2
bind = $mainMod SHIFT, 3, split-movetoworkspacesilent, 3
bind = $mainMod SHIFT, 4, split-movetoworkspacesilent, 4
bind = $mainMod SHIFT, 5, split-movetoworkspacesilent, 5
bind = $mainMod SHIFT, 6, split-movetoworkspacesilent, 6
bind = $mainMod SHIFT, 7, split-movetoworkspacesilent, 7
bind = $mainMod SHIFT, 8, split-movetoworkspacesilent, 8
bind = $mainMod SHIFT, 9, split-movetoworkspacesilent, 9
bind = $mainMod SHIFT, 0, split-movetoworkspacesilent, 10
# Example special workspace (scratchpad)
bind = $mainMod, S, togglespecialworkspace, magic
bind = $mainMod SHIFT, S, movetoworkspace, special:magic
# Have scratchpad like DWM
workspace = special:h, on-created-empty: $terminal
bind = $mainMod SHIFT, Return, togglespecialworkspace, h
# --- Screen Rotate ---
bindld = CTRL ALT, R, Rotate Screen Clockwise, exec, hypr_screen_rotate.sh -90
bindld = CTRL ALT SHIFT, R, Rotate Screen Anti-Clockwise, exec, hypr_screen_rotate.sh +90
# --- Accessibility: Zoom ---
cursor:zoom_disable_aa = true
# Zoom In
binded = SUPER SHIFT, equal, Zoom In, exec, sh -c "hyprctl keyword cursor:zoom_factor \"$(hyprctl getoption cursor:zoom_factor | awk 'NR==1 {print $2 * 1.25}')\""
# Zoom Out
binded = SUPER SHIFT, minus, Zoom Out, exec, sh -c "hyprctl keyword cursor:zoom_factor \"$(hyprctl getoption cursor:zoom_factor | awk 'NR==1 {val = $2 / 1.25; if (val < 1.0) val = 1.0; print val}')\""
# Reset Zoom
bindld = SUPER SHIFT, BACKSPACE, Reset Zoom, exec, hyprctl keyword cursor:zoom_factor 1.0
# Scroll through existing workspaces with mainMod + scroll
bind = $mainMod, mouse_down, workspace, e+1
bind = $mainMod, mouse_up, workspace, e-1
# Move/resize windows with mainMod + LMB/RMB and dragging
bindm = $mainMod, mouse:272, movewindow
bindm = $mainMod, mouse:273, resizewindow
# Laptop multimedia keys for volume and LCD brightness
bindel = ,XF86AudioRaiseVolume, exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+
bindel = ,XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bindel = ,XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle
bindel = ,XF86AudioMicMute, exec, wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
bindel = , XF86MonBrightnessDown, exec, ~/.local/bin/brictl -
bindel = , XF86MonBrightnessUp, exec, ~/.local/bin/brictl +
# Requires playerctl
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioPause, exec, playerctl play-pause
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPrev, exec, playerctl previous

View File

@ -0,0 +1,12 @@
ecosystem {
enforce_permissions = 1
}
permission = /usr/(bin|local/bin)/grim, screencopy, allow
permission = /usr/(bin|local/bin)/hyprlock, screencopy, allow
permission = /usr/(bin|local/bin)/hyprpicker , screencopy, allow
permission = /usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland, screencopy, allow
permission = /usr/(bin|local/bin)/hyprpm, plugin, allow
permission = ${lib.escapeRegex (lib.getExe config.programs.hyprlock.package)}, screencopy, allow

114
.local/bin/hypr/screen_rotate.sh Executable file
View File

@ -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

View File

@ -12,7 +12,6 @@ case "$(printf "a selected area (copy)\ncurrent window (copy)\nfull screen (copy
"full screen") hyprshot -m output -o ~/pix/ss -f "pic-full-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; "full screen") hyprshot -m output -o ~/pix/ss -f "pic-full-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;;
"a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && \ "a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && \
hyprshot -m region -o "$(dirname "$tmpfile")" -f "$(basename "$tmpfile")" && \ slurp | grim -g - - | tesseract stdin stdout -l eng | wl-copy
tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;;
esac esac