custom-hypr - add script for hyprland

This commit is contained in:
huyjaky
2024-10-21 22:55:13 +07:00
parent 0cf0beb8c7
commit 39467b1bbe
9 changed files with 167 additions and 11 deletions

View File

@@ -1,2 +0,0 @@
env = PRIMARY_MONITOR_WORKSPACE,3
env = SECONDARY_MONITOR_WORKSPACE,4

View File

@@ -4,4 +4,5 @@
exec-once = corectrl
exec-once = otd-daemon # run driver veikk
exec-once = fcitx5
exec = gsettings set org.gnome.desktop.interface icon-theme 'Tela-circle-blue'

View File

@@ -34,19 +34,18 @@ bind = Alt, J, movefocus, d # [hidden]
##! Window arrangement
#/# bind = Super+Shift, ←/↑/→/↓,, # Window: move in direction
bind = Ctrl+Alt, H, fullscreenstate, 0 # [hidden]
bind = Ctrl+Alt, H, movewindow, l # [hidden]
bind = Ctrl+Alt, H, exec, source /home/duckq1u/.config/hypr/scripts/windowtoleft.sh # [hidden]
# bind = Ctrl+Alt, H, movewindow, l # [hidden]
bind = Ctrl+Alt, L, fullscreenstate, 0 # [hidden]
bind = Ctrl+Alt, L, movewindow, r # [hidden]
# bind = Ctrl+Alt, L, fullscreenstate, 0 # [hidden]
bind = Ctrl+Alt, L, exec, source /home/duckq1u/.config/hypr/scripts/windowtoright.sh # [hidden]
bind = Ctrl+Alt, K, movewindow, u # [hidden]
bind = Ctrl+Alt, J, movewindow, d # [hidden]
# bind = Ctrl+Alt, M, exec, pavucontrol # Launch pavucontrol (volume mixer)
bind = Alt, Q, killactive,
bind = Alt, F, fullscreen, 0
bind = Alt, F, fullscreen, 1
bind = Alt, R, exec, killall ags ydotool; ags & # Restart widgets
bind = Alt, E, exec, nautilus --new-window # Launch Nautilus (file manager)
# bind = Alt, M, exec, ags run-js 'openMusicControls.value = (!mpris.getPlayer() ? false : !openMusicControls.value);' # Toggle music controls
@@ -67,8 +66,8 @@ bind = SUPER, SUPER_L, exec, pkill -x rofi || $scrPath/rofilaunch.sh d # launch
# bind = Shift+Alt, L, exec, source /home/duckq1u/.config/hypr/scripts/workspacePLUS.sh
# bind = Shift+Alt, H, exec, source /home/duckq1u/.config/hypr/scripts/workspaceEXCEPT.sh
bind = Shift+Alt, L, exec, source /home/duckq1u/.config/hypr/scripts/workspaceV2.sh
bind = Shift+Alt, H, exec, source /home/duckq1u/.config/hypr/scripts/workspaceV2except.sh
bind = Shift+Alt, L, exec, source /home/duckq1u/.config/hypr/scripts/workspaceV2inscrease.sh
bind = Shift+Alt, H, exec, source /home/duckq1u/.config/hypr/scripts/workspaceV2descrease.sh
$mainMod = Super # super / meta / windows key

View File

@@ -0,0 +1,61 @@
#!/bin/bash
# Lấy thông tin của cửa sổ hiện tại chỉ một lần
window_info=$(hyprctl activewindow)
# Trích xuất giá trị cần thiết từ window_info
# 1892
window_x_position=$(echo "$window_info" | grep -oP '(?<=at: )\d+')
window_at_monitor=$(echo "$window_info" | grep 'monitor' | awk '{print $2}')
window_at_workspace=$(echo "$window_info" | grep 'workspace' | awk '{print $2}')
window_state=$(echo "$window_info" | grep 'fullscreen:' | awk '{print $2}')
current_workspace=$(hyprctl activeworkspace | grep 'workspace' | awk '{print $3}')
window_width=$(echo "$window_info" | grep 'size:' | awk '{print $2}' | cut -d',' -f1)
echo $window_stat
echo $window_x_position
echo $window_width
hyprctl dispatch fullscreenstate 0 # minimize trước khi di chuyển
# NOTE: Di chuyển cửa sổ nếu vị trí X vượt qua ngưỡng
if [ $window_x_position -eq 14 ] && [ $window_state -eq 1 ]; then
if [ $current_workspace -eq 1 ]; then
exit 1
fi
hyprctl dispatch movetoworkspace $((window_at_workspace-1))
hyprctl dispatch focusmonitor 0
hyprctl dispatch workspace $((current_workspace-2))
hyprctl dispatch focusmonitor 1
exit 0
fi
if [ $window_x_position -eq 14 ] && [ $window_width -eq 1892 ]; then
if [ $current_workspace -eq 1 ]; then
exit 1
fi
hyprctl dispatch movetoworkspace $((window_at_workspace-1))
hyprctl dispatch focusmonitor 0
hyprctl dispatch workspace $((current_workspace-2))
hyprctl dispatch focusmonitor 1
exit 0
fi
if [ $window_x_position -eq 14 ]; then
if [ $current_workspace -eq 1 ]; then
exit 1
fi
hyprctl dispatch movetoworkspace $((window_at_workspace-1))
hyprctl dispatch focusmonitor 0
hyprctl dispatch workspace $((current_workspace-2))
hyprctl dispatch focusmonitor 1
exit 0
fi
# Nếu không thoả điều kiện di chuyển, di chuyển cửa sổ sang phải
hyprctl dispatch movewindow l

View File

@@ -0,0 +1,61 @@
#!/bin/bash
# Lấy thông tin của cửa sổ hiện tại chỉ một lần
window_info=$(hyprctl activewindow)
# Trích xuất giá trị cần thiết từ window_info
# 1892
window_x_position=$(echo "$window_info" | grep -oP '(?<=at: )\d+')
window_at_monitor=$(echo "$window_info" | grep 'monitor' | awk '{print $2}')
window_at_workspace=$(echo "$window_info" | grep 'workspace' | awk '{print $2}')
window_state=$(echo "$window_info" | grep 'fullscreen:' | awk '{print $2}')
current_workspace=$(hyprctl activeworkspace | grep 'workspace' | awk '{print $3}')
window_width=$(echo "$window_info" | grep 'size:' | awk '{print $2}' | cut -d',' -f1)
echo $window_stat
echo $window_x_position
echo $window_width
hyprctl dispatch fullscreenstate 0 # minimize trước khi di chuyển
# NOTE: Di chuyển cửa sổ nếu vị trí X vượt qua ngưỡng
if [ $window_x_position -eq 1934 ] && [ $window_state -eq 1 ]; then
if [ $current_workspace -eq 6 ]; then
exit 1
fi
hyprctl dispatch movetoworkspace $((window_at_workspace+1))
hyprctl dispatch focusmonitor 1
hyprctl dispatch workspace $((current_workspace+2))
hyprctl dispatch focusmonitor 0
exit 0
fi
if [ $window_x_position -eq 1934 ] && [ $window_width -eq 1892 ]; then
if [ $current_workspace -eq 6 ]; then
exit 1
fi
hyprctl dispatch movetoworkspace $((window_at_workspace+1))
hyprctl dispatch focusmonitor 1
hyprctl dispatch workspace $((current_workspace+2))
hyprctl dispatch focusmonitor 0
exit 0
fi
if [ $window_x_position -eq 2990 ]; then
if [ $current_workspace -eq 6 ]; then
exit 1
fi
hyprctl dispatch movetoworkspace $((window_at_workspace+1))
hyprctl dispatch focusmonitor 1
hyprctl dispatch workspace $((current_workspace+2))
hyprctl dispatch focusmonitor 0
exit 0
fi
# Nếu không thoả điều kiện di chuyển, di chuyển cửa sổ sang phải
hyprctl dispatch movewindow r

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# Extract workspace ID from the output of hyprctl activewindow
current_monitor=$(hyprctl activeworkspace | grep 'monitorID' | awk '{print $2}')
current_workspace=$(hyprctl activeworkspace | grep 'workspace' | awk '{print $3}')
# Determine the second workspace based on whether the current workspace is even or odd
if [ $((current_workspace % 2)) -eq 0 ]; then
second_workspace=$((current_workspace - 1))
else
second_workspace=$((current_workspace + 1))
fi
# Assign primary and secondary monitor workspaces based on the current workspace
if [ $((current_workspace % 2)) -eq 0 ]; then
primary_monitor_workspace=$((second_workspace + 2)) # left
secondary_monitor_workspace=$((current_workspace + 2)) # right
else
primary_monitor_workspace=$((current_workspace + 2))
secondary_monitor_workspace=$((second_workspace + 2))
fi
# Check if primary_monitor_workspace is less than or equal to 0
# or if secondary_monitor_workspace is greater than or equal to 11
if [ "$primary_monitor_workspace" -le 0 ] || [ "$secondary_monitor_workspace" -ge 7 ]; then
exit 1
fi
# Switch focus and workspace for both monitors
hyprctl dispatch focusmonitor 0
hyprctl dispatch workspace $primary_monitor_workspace
hyprctl dispatch focusmonitor 1
hyprctl dispatch workspace $secondary_monitor_workspace
# Optionally focus back to the original monitor if desired (adjust this part if needed)
hyprctl dispatch focusmonitor 0

View File

@@ -5,7 +5,7 @@
# |____| \______ /|__| / ____|| __/|__|
# \/ \/ |__|
exec = gsettings set org.gnome.desktop.interface icon-theme 'Gruvbox-Plus-Dark'
exec = gsettings set org.gnome.desktop.interface icon-theme 'Uos'
# exec = gsettings set org.gnome.desktop.interface gtk-theme 'Gruvbox-Retro'
# exec = gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'