- better handle undecorated windows
- gap support
This commit is contained in:
parent
6899f7b8bd
commit
925cf71b19
8
CHANGELOG.md
Normal file
8
CHANGELOG.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
## Changelog
|
||||||
|
|
||||||
|
### 4.05.2021
|
||||||
|
- handle undecorated windows
|
||||||
|
- handle gap
|
||||||
|
|
||||||
|
### 3.05.2021
|
||||||
|
- initial "quick and dirty" version
|
@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
clicksnap for Openbox - click on the appropriate area of the window to snap it in a given direction.
|
clicksnap for Openbox - click on the appropriate area of the window to snap it in a given direction.
|
||||||
Works with active and inactive windows.
|
Works with active and inactive windows.
|
||||||
|
Configurable gap between windows.
|
||||||
|
|
||||||
*(Far from perfection, but imho already enough good to use)*
|
*(Far from perfection, but imho already enough good to use)*
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
- wmctrl
|
- wmctrl
|
||||||
- xdotool
|
- xdotool
|
||||||
|
- xwininfo
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
wget https://git.maboxlinux.org/napcok/clicksnap/raw/branch/master/clicksnap
|
wget https://git.maboxlinux.org/napcok/clicksnap/raw/branch/master/clicksnap
|
||||||
@ -22,9 +24,13 @@ Add this mousebind action to context Frame:
|
|||||||
</action>
|
</action>
|
||||||
</mousebind>
|
</mousebind>
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
clicksnap is binded to <kbd>Ctrl</kbd> + <kbd>Left Mouse Click</kbd>
|
clicksnap is binded to <kbd>Ctrl</kbd> + <kbd>Left Mouse Click</kbd>
|
||||||
Click inside window you like to move.
|
Click inside window you like to move.
|
||||||
There are 9 areas ... see screenshot :)
|
There are 9 areas ... see screenshot :)
|
||||||
|
|
||||||
![clicksnap](clicksnap.png "clicksnap areas")
|
![clicksnap](clicksnap.png "clicksnap areas")
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
82
clicksnap
82
clicksnap
@ -1,17 +1,32 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
## clicksnap - click on the appropriate area of the window to snap it in a given direction.
|
### clicksnap - click on the appropriate area of the window to snap it in a given direction.
|
||||||
# Works with active and inactive windows
|
# Works with active and inactive windows
|
||||||
|
# Author: Daniel Napora <napcok@gmail.com>
|
||||||
|
# https://maboxlinux.org
|
||||||
#
|
#
|
||||||
#
|
### Configuration
|
||||||
#
|
# Gap between windows
|
||||||
#
|
GAP="32"
|
||||||
##
|
# TITLEBAR HEIGHT - no idea how to find it from cli
|
||||||
|
TITLEBAR_HEIGHT="20"
|
||||||
|
# Activate moved windows?
|
||||||
activate_window="false"
|
activate_window="false"
|
||||||
|
### End Configuration
|
||||||
|
|
||||||
eval $(xdotool getmouselocation --shell)
|
eval $(xdotool getmouselocation --shell)
|
||||||
Mouse_x="$X"
|
Mouse_x="$X"
|
||||||
Mouse_y="$Y"
|
Mouse_y="$Y"
|
||||||
|
|
||||||
|
HEX_ID=$(printf '0x%x\n' $WINDOW)
|
||||||
|
|
||||||
|
CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}')
|
||||||
|
|
||||||
|
if xwininfo -id $CHILD_ID -wm |grep Undecorated ; then # Undecorated
|
||||||
|
T="0"
|
||||||
|
else # Decorated
|
||||||
|
T="$TITLEBAR_HEIGHT"
|
||||||
|
fi
|
||||||
|
|
||||||
eval $(xdotool getwindowgeometry --shell $WINDOW)
|
eval $(xdotool getwindowgeometry --shell $WINDOW)
|
||||||
Win_x="$X"
|
Win_x="$X"
|
||||||
Win_y="$Y"
|
Win_y="$Y"
|
||||||
@ -36,61 +51,26 @@ OFF_Y="${OFFSET#*,}"
|
|||||||
|
|
||||||
case $POS_CODE in
|
case $POS_CODE in
|
||||||
00) # top-left
|
00) # top-left
|
||||||
WIDTH=$((AVAIL_X/2))
|
W=$((AVAIL_X/2-GAP)) H=$((AVAIL_Y/2-T-GAP)) X=$((0+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y/2))
|
|
||||||
X=$((0+OFF_X))
|
|
||||||
Y=$((0+OFF_Y))
|
|
||||||
;;
|
|
||||||
10) # top
|
10) # top
|
||||||
WIDTH=$((AVAIL_X))
|
W=$((AVAIL_X-GAP)) H=$((AVAIL_Y/2-T-GAP)) X=$((0+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y/2))
|
|
||||||
X=$((0+OFF_X))
|
|
||||||
Y=$((0+OFF_Y))
|
|
||||||
;;
|
|
||||||
20) # top-right
|
20) # top-right
|
||||||
WIDTH=$((AVAIL_X/2))
|
W=$((AVAIL_X/2-GAP)) H=$((AVAIL_Y/2-T-GAP)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y/2))
|
|
||||||
X=$((AVAIL_X/2+OFF_X))
|
|
||||||
Y=$((0+OFF_Y))
|
|
||||||
;;
|
|
||||||
01) # left
|
01) # left
|
||||||
WIDTH=$((AVAIL_X/2))
|
W=$((AVAIL_X/2-GAP)) H=$((AVAIL_Y-T-GAP)) X=$((0+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y-OFF_Y/2))
|
|
||||||
X=$((0+OFF_X))
|
|
||||||
Y=$((0+OFF_Y))
|
|
||||||
;;
|
|
||||||
11) # center
|
11) # center
|
||||||
WIDTH=$((AVAIL_X/2-OFF_X))
|
W=$((AVAIL_X/8*6-OFF_X)) H=$((AVAIL_Y/8*6-T)) X=$((AVAIL_X/8+OFF_X/2)) Y=$((AVAIL_Y/8+OFF_Y/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y))
|
|
||||||
X=$((AVAIL_X/4+OFF_X/2))
|
|
||||||
Y=$((AVAIL_Y/4+OFF_Y/2));;
|
|
||||||
21) # right
|
21) # right
|
||||||
WIDTH=$((AVAIL_X/2))
|
W=$((AVAIL_X/2-GAP)) H=$((AVAIL_Y-T-GAP)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((0+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y-OFF_Y/2))
|
|
||||||
X=$((AVAIL_X/2+OFF_X))
|
|
||||||
Y=$((0+OFF_Y))
|
|
||||||
;;
|
|
||||||
02) # bottom-left
|
02) # bottom-left
|
||||||
WIDTH=$((AVAIL_X/2))
|
W=$((AVAIL_X/2-GAP)) H=$((AVAIL_Y/2-T-GAP)) X=$((0+OFF_X+GAP/2)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y/2))
|
|
||||||
X=$((0+OFF_X))
|
|
||||||
Y=$((AVAIL_Y/2+OFF_Y))
|
|
||||||
;;
|
|
||||||
12) # bottom
|
12) # bottom
|
||||||
WIDTH=$((AVAIL_X))
|
W=$((AVAIL_X-GAP)) H=$((AVAIL_Y/2-T-GAP)) X=$((0+OFF_X+GAP/2)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y/2))
|
|
||||||
X=$((0+OFF_X))
|
|
||||||
Y=$((AVAIL_Y/2+OFF_Y))
|
|
||||||
;;
|
|
||||||
22) # bottom-right
|
22) # bottom-right
|
||||||
WIDTH=$((AVAIL_X/2))
|
W=$((AVAIL_X/2-GAP)) H=$((AVAIL_Y/2-T-GAP)) X=$((AVAIL_X/2+OFF_X+GAP/2)) Y=$((AVAIL_Y/2+OFF_Y+GAP/2));;
|
||||||
HEIGHT=$((AVAIL_Y/2-OFF_Y/2))
|
|
||||||
X=$((AVAIL_X/2+OFF_X))
|
|
||||||
Y=$((AVAIL_Y/2+OFF_Y))
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
xdotool windowsize $WINDOW $WIDTH $HEIGHT
|
xdotool windowsize $WINDOW $W $H
|
||||||
xdotool windowmove $WINDOW $X $Y
|
xdotool windowmove $WINDOW $X $Y
|
||||||
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi
|
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi
|
||||||
|
Loading…
Reference in New Issue
Block a user