custom-hypr - synchronously multiple call

This commit is contained in:
huyjaky
2024-11-04 13:33:15 +07:00
parent d0d707a0c0
commit 1b2d31728e
11 changed files with 75 additions and 69 deletions

View File

@@ -13,23 +13,30 @@ 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
move(){
# hyprctl dispatch movetoworkspace $((window_at_workspace-1)) \
# && hyprctl dispatch focusmonitor 0 \
# && hyprctl dispatch workspace $((current_workspace-2)) \
# && hyprctl dispatch focusmonitor 1
hyprctl --batch "
dispatch movetoworkspace $((window_at_workspace-1)) ;
dispatch focusmonitor 0 ;
dispatch workspace $((current_workspace-2)) ;
dispatch focusmonitor 1
"
exit 0
}
# 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
move
fi
if [ $window_x_position -eq 14 ] && [ $window_width -eq 1892 ]; then
@@ -37,11 +44,7 @@ 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
move
fi
@@ -50,11 +53,7 @@ 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
move
fi
# Nếu không thoả điều kiện di chuyển, di chuyển cửa sổ sang phải

View File

@@ -12,23 +12,30 @@ 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
move(){
# hyprctl dispatch movetoworkspace $((window_at_workspace+1)) \
# && hyprctl dispatch focusmonitor 1 \
# && hyprctl dispatch workspace $((current_workspace+2)) \
# && hyprctl dispatch focusmonitor 0
hyprctl --batch "
dispatch movetoworkspace $((window_at_workspace+1)) ;
dispatch focusmonitor 1 ;
dispatch workspace $((current_workspace+2)) ;
dispatch focusmonitor 0
"
exit 0
}
# 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 8 ]; 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
move
fi
if [ $window_x_position -eq 1934 ] && [ $window_width -eq 1892 ]; then
@@ -36,11 +43,7 @@ if [ $window_x_position -eq 1934 ] && [ $window_width -eq 1892 ]; then
if [ $current_workspace -eq 8 ]; 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
move
fi
@@ -49,11 +52,7 @@ if [ $window_x_position -eq 2990 ]; then
if [ $current_workspace -eq 8 ]; 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
move
fi
# Nếu không thoả điều kiện di chuyển, di chuyển cửa sổ sang phải

View File

@@ -25,10 +25,18 @@ if [ "$primary_monitor_workspace" -le 0 ] || [ "$secondary_monitor_workspace" -g
exit 1
fi
# hyprctl dispatch focusmonitor 0 \
# &&hyprctl dispatch workspace $primary_monitor_workspace \
# &&hyprctl dispatch focusmonitor 1 \
# &&hyprctl dispatch workspace $secondary_monitor_workspace \
# &&hyprctl dispatch focusmonitor $current_monitor
hyprctl --batch "
dispatch focusmonitor 0 ;
dispatch workspace $primary_monitor_workspace ;
dispatch dispatch focusmonitor 1 ;
dispatch workspace $secondary_monitor_workspace ;
dispatch focusmonitor $current_monitor
"
hyprctl dispatch focusmonitor 0 \
&&hyprctl dispatch workspace $primary_monitor_workspace \
&&hyprctl dispatch focusmonitor 1 \
&&hyprctl dispatch workspace $secondary_monitor_workspace \
&&hyprctl dispatch focusmonitor $current_monitor
exit 0

View File

@@ -26,9 +26,18 @@ if [ "$primary_monitor_workspace" -le 0 ] || [ "$secondary_monitor_workspace" -g
exit 1
fi
hyprctl dispatch focusmonitor 0 \
&&hyprctl dispatch workspace $primary_monitor_workspace \
&&hyprctl dispatch focusmonitor 1 \
&&hyprctl dispatch workspace $secondary_monitor_workspace \
&&hyprctl dispatch focusmonitor $current_monitor
# hyprctl dispatch focusmonitor 0 \
# &&hyprctl dispatch workspace $primary_monitor_workspace \
# &&hyprctl dispatch focusmonitor 1 \
# &&hyprctl dispatch workspace $secondary_monitor_workspace \
# &&hyprctl dispatch focusmonitor $current_monitor
hyprctl --batch "
dispatch focusmonitor 0 ;
dispatch workspace $primary_monitor_workspace ;
dispatch dispatch focusmonitor 1 ;
dispatch workspace $secondary_monitor_workspace ;
dispatch focusmonitor $current_monitor
"
exit 0