Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@YCF
Last active December 30, 2020 17:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YCF/5a5da13669fb15e0bea25179ef4e72a3 to your computer and use it in GitHub Desktop.
Save YCF/5a5da13669fb15e0bea25179ef4e72a3 to your computer and use it in GitHub Desktop.
通过快捷键快速缩放窗口,实现窗口的伪造平铺
#伪平铺特性
#
# q w e LeftTop Max RightTop
# super + shift +: a s d ===> Left Center Right
# z x c LeftBottom unMax RightBottom
#
super + shift + {q,w,e,a,s,d,z,x,c}
sh -c "~/.config/sxhkd/window.sh {LT,M,RT,L,C,R,LB,U,RB}"
#!/bin/bash
# resizes & places the window
#define the height in px of the top system-bar:
TOPMARGIN=16
#sum in px of all horizontal borders:
RIGHTMARGIN=10
# get width of screen and height of screen
SCREEN_WIDTH=$(xwininfo -root | awk '$1=="Width:" {print $2}')
SCREEN_HEIGHT=$(xwininfo -root | awk '$1=="Height:" {print $2}')
Full_W=$SCREEN_WIDTH
Haft_W=$(( $SCREEN_WIDTH / 2 - $RIGHTMARGIN ))
Full_H=$(( $SCREEN_HEIGHT - 2 * $TOPMARGIN ))
Haft_H=$(( ($SCREEN_HEIGHT - $TOPMARGIN) /2 ))
# Left
L_W=$Haft_W
L_H=$Full_H
L_X=0;
L_Y=$TOPMARGIN
# Left Top
LT_W=$Haft_W
LT_H=$Haft_H
LT_X=0;
LT_Y=$TOPMARGIN
#Left Bottom
LB_W=$Haft_W
LB_H=$Haft_H
LB_X=0;
LB_Y=$(( $SCREEN_HEIGHT/2 + $TOPMARGIN ))
#Right
R_W=$Haft_W
R_H=$Full_H
R_X=$(( $SCREEN_WIDTH / 2 ))
R_Y=$TOPMARGIN
#Right Top
RT_W=$Haft_W
RT_H=$Haft_H
RT_X=$(( $SCREEN_WIDTH / 2 ))
RT_Y=$TOPMARGIN
#Right Bottom
RB_W=$Haft_W
RB_H=$Haft_H
RB_X=$(( $SCREEN_WIDTH / 2 ))
RB_Y=$(( $SCREEN_HEIGHT/2 + $TOPMARGIN ))
#Center
C_W=$Haft_W
C_H=$Haft_H
C_X=$(( $SCREEN_WIDTH/2 - $Haft_W/2 ))
C_Y=$(( $SCREEN_HEIGHT/2 - $Haft_H/2 ))
case "$1" in
"L") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$L_X,$L_Y,$L_W,$L_H ;;
"LT") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$LT_X,$LT_Y,$LT_W,$LT_H ;;
"LB") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$LB_X,$LB_Y,$LB_W,$LB_H ;;
"M") wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz ;;
"C") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$C_X,$C_Y,$C_W,$C_H ;;
"U") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz ;;
"R") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$R_X,$R_Y,$R_W,$R_H ;;
"RT") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$RT_X,$RT_Y,$RT_W,$RT_H ;;
"RB") wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$RB_X,$RB_Y,$RB_W,$RB_H ;;
*) printf "%s\n" "Usage: ./window [L,R,LT,LB,RT,RB,M,U,C]"; exit ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment