update
This commit is contained in:
parent
f69bc67c48
commit
e4516996cb
15
bin/deskgrid
15
bin/deskgrid
@ -1,27 +1,20 @@
|
||||
#!/bin/bash
|
||||
### deskgrid - click on the window and select area to place it on the grid
|
||||
# Works with active and inactive windows
|
||||
# (C) Daniel Napora <napcok@gmail.com>, 2021-22
|
||||
# (C) Daniel Napora <napcok@gmail.com>, 2021-24
|
||||
# https://maboxlinux.org
|
||||
#
|
||||
|
||||
|
||||
CONFIG_DIR=~/.config/deskgrid
|
||||
CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg"
|
||||
CONFIG_FILE="$HOME/.config/superclick.cfg"
|
||||
mkdir -p $CONFIG_DIR
|
||||
if [ ! -f $CONFIG_FILE ]; then
|
||||
cat <<EOF > ${CONFIG_FILE}
|
||||
# Gap between windows in pixels (reasonable values: 0 8 16 24)
|
||||
gap=16
|
||||
# Grid columns (12 16 24)
|
||||
columns=12
|
||||
# Grid rows (6 12 16)
|
||||
rows=12
|
||||
#Notifications true or false
|
||||
notifications=true
|
||||
# Outer gap (disable if you use WM margins)
|
||||
show_outer_gap=true
|
||||
# Only for clicksnap action
|
||||
# Only for clicksnap (mouse) action
|
||||
activate_window=false
|
||||
EOF
|
||||
fi
|
||||
@ -30,7 +23,7 @@ source <(grep = $CONFIG_FILE)
|
||||
GAP=${gap:-16}
|
||||
COLUMNS=${columns:-12}
|
||||
ROWS=${rows:-12}
|
||||
TITLEBAR_HEIGHT=${titlebar_height:-18}
|
||||
#TITLEBAR_HEIGHT=${titlebar_height:-18}
|
||||
|
||||
case "$LANG" in
|
||||
pl*)
|
||||
|
18
bin/drawgrid
18
bin/drawgrid
@ -1,22 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONFIG_DIR="$HOME/.config/deskgrid"
|
||||
CONFIG_FILE="$CONFIG_DIR/deskgrid.cfg"
|
||||
CONFIG_FILE="$HOME/.config/superclick.cfg"
|
||||
mkdir -p $CONFIG_DIR
|
||||
if [ ! -f $CONFIG_FILE ]; then
|
||||
cat <<EOF > ${CONFIG_FILE}
|
||||
# Gap between windows in pixels (reasonable values: 0 8 16 24)
|
||||
gap=16
|
||||
# Grid columns (12 16 24)
|
||||
columns=12
|
||||
# Grid rows (6 12 16)
|
||||
rows=12
|
||||
#
|
||||
#Notifications true or false
|
||||
notifications=true
|
||||
# Outer gap (disable if you use WM margins)
|
||||
show_outer_gap=true
|
||||
# Only for clicksnap action
|
||||
# Only for clicksnap (mouse) action
|
||||
activate_window=false
|
||||
EOF
|
||||
fi
|
||||
@ -24,7 +16,7 @@ source <(grep = $CONFIG_FILE)
|
||||
|
||||
GAP=${gap:-16}
|
||||
COLUMNS=${columns:-12}
|
||||
ROWS=${rows:-6}
|
||||
ROWS=${rows:-12}
|
||||
|
||||
AVAILSIZE=$(wmctrl -d |grep "*"|awk -F' ' '{print $9}')
|
||||
AVAIL_X="${AVAILSIZE%x*}"
|
||||
@ -45,9 +37,9 @@ rectangles=""
|
||||
name="text 24,96 DesktopGrid"
|
||||
case $LANG in
|
||||
pl*)
|
||||
text="text 30,128 \"Ten obrazek ma pomóc ci zaprzyjaźnić się z siatką pulpitu DesktopGrid.\nDesktopGrid pozwala na dokładne ułożenie okien na pulpicie z opcjonalnym (konfigurowalnym) odstępem.\nJak to działa?\n1. Trzymając klawisz super(windows), kliknij wewnątrz okna które chcesz przemieścić. Okno zostanie zminimalizowane.\n2. Wyznacz myszą nową pozycję dla okna zaznaczając prostokąt\n3. Okno jest ustawiane wewnątrz siatki obliczonej na podstawie zaznaczenia.\n\nUżyj paska zadań aby schować/pokazać tło.\nAby wyłączyć tło: klik środkowym myszy na pasku zadań lub kliknięcie na obrazku i klawisz q\n\nSiatka: kolumny:$COLUMNS, wiersze:$ROWS, odstęp:$GAP\nRozmiar pojedyńczej komórki: $TILE_WIDTH x $TILE_HEIGHT\"";;
|
||||
text="text 30,128 \"Ten obrazek ma pomóc ci zaprzyjaźnić się z siatką pulpitu DesktopGrid.\nDesktopGrid pozwala na dokładne ułożenie okien na pulpicie z opcjonalnym (konfigurowalnym) odstępem.\nJak to działa?\n1. Trzymając klawisze CTRL + SHIFT, kliknij wewnątrz okna które chcesz przemieścić. Okno zostanie zminimalizowane.\n2. Wyznacz myszą nową pozycję dla okna zaznaczając prostokąt\n3. Okno jest ustawiane wewnątrz siatki obliczonej na podstawie zaznaczenia.\n\nUżyj paska zadań aby schować/pokazać tło.\nAby wyłączyć tło: klik środkowym myszy na pasku zadań lub kliknięcie na obrazku i klawisz q\n\nSiatka: kolumny:$COLUMNS, wiersze:$ROWS, odstęp:$GAP\nRozmiar pojedyńczej komórki: $TILE_WIDTH x $TILE_HEIGHT\"";;
|
||||
*)
|
||||
text="text 30,128 \"This background image is here to help you get familiar with DesktopGrid.\nDesktopGrid allows you to accurately arrange windows on the desktop with optional gap (configurable).\nHow it's working?\n1. While holding down the super (windows) key, click inside the window you want to move. The window will be minimized.\n2. Use the mouse to mark a new position for the window by selecting the rectangle\n3. The window is positioned within the computed grid from the selection.\n\nCurrent Grid settings: $COLUMNS columns, $ROWS rows, gap:$GAP\nSingle tile size: $TILE_WIDTH x $TILE_HEIGHT\n\nUse mousewheel on taskbar to show/hide this background.\nTo close: middle click on taskbar or click here, then hit q key\""
|
||||
text="text 30,128 \"This background image is here to help you get familiar with DesktopGrid.\nDesktopGrid allows you to accurately arrange windows on the desktop with optional gap (configurable).\nHow it's working?\n1. While holding down CTRL+ SHIFT keys, click inside the window you want to move. The window will be minimized.\n2. Use the mouse to mark a new position for the window by selecting the rectangle\n3. The window is positioned within the computed grid from the selection.\n\nCurrent Grid settings: $COLUMNS columns, $ROWS rows, gap:$GAP\nSingle tile size: $TILE_WIDTH x $TILE_HEIGHT\n\nUse mousewheel on taskbar to show/hide this background.\nTo close: middle click on taskbar or click here, then hit q key\""
|
||||
;;
|
||||
esac
|
||||
magick -size $AVAILSIZE xc:LavenderBlush3 -stroke LavenderBlush2 -strokewidth 1 \
|
||||
|
@ -1,24 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Author: Daniel Napora <napcok@gmail.com>
|
||||
# Author: Daniel Napora <napcok@gmail.com> 2018-2024
|
||||
# "Show-Hide" terminal wrapper for terminator for use with keybind eg. C-~ or F12.
|
||||
# Depenging on actual state it will start, show or hide terminal window.
|
||||
|
||||
GEOMETRY_FILE="$HOME/.config/mabox/.quake-term"
|
||||
NAME="quake-term"
|
||||
NAME="Quake Term"
|
||||
|
||||
__run() {
|
||||
ID=$(wmctrl -x -l | grep ${NAME} | awk '{print $1}' | head -n 1)
|
||||
ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1)
|
||||
if [ -z "${ID}" ]; then
|
||||
if [ -f "$GEOMETRY_FILE" ]; then
|
||||
POS=$(head -n 1 $GEOMETRY_FILE)
|
||||
terminator -T ${NAME} -b --geometry "$POS" -i utilities-terminal
|
||||
terminator -T "${NAME}" -b --geometry "$POS" -i utilities-terminal
|
||||
else
|
||||
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
|
||||
LEFT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/8]
|
||||
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
|
||||
WIDTH=$[${LEFT}*6]
|
||||
terminator -T ${NAME} -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -i utilities-terminal
|
||||
terminator -T "${NAME}" -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -i utilities-terminal
|
||||
fi
|
||||
else
|
||||
ID_DEC=$((${ID}))
|
||||
@ -28,7 +28,7 @@ else
|
||||
else
|
||||
xdotool windowactivate ${ID_DEC}
|
||||
fi
|
||||
eval $(xdotool getwindowgeometry --shell $(xdotool search --name $NAME))
|
||||
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
|
||||
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
|
||||
fi
|
||||
}
|
||||
|
68
bin/quake-radio
Executable file
68
bin/quake-radio
Executable file
@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
# Show/hide terminal with pyradio.
|
||||
|
||||
|
||||
GEOMETRY_FILE="$HOME/.config/.quake-radio"
|
||||
TERM_CONFIG="$HOME/.config/terminator/transparent"
|
||||
NAME="Quake Radio"
|
||||
|
||||
__run() {
|
||||
ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1)
|
||||
if [ -z "${ID}" ]; then
|
||||
if [ ! -f $TERM_CONFIG ]; then
|
||||
cat <<EOF > ${TERM_CONFIG}
|
||||
[global_config]
|
||||
dbus = False
|
||||
[keybindings]
|
||||
[profiles]
|
||||
[[default]]
|
||||
allow_bold = False
|
||||
background_darkness = 0.0
|
||||
background_type = transparent
|
||||
cursor_blink = False
|
||||
cursor_color = "#aaaaaa"
|
||||
show_titlebar = False
|
||||
scrollbar_position = hidden
|
||||
scroll_on_keystroke = False
|
||||
use_custom_command = False
|
||||
use_system_font = False
|
||||
[layouts]
|
||||
[plugins]
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ -f "$GEOMETRY_FILE" ]; then
|
||||
POS=$(head -n 1 $GEOMETRY_FILE)
|
||||
terminator -b -g "${TERM_CONFIG}" -T "${NAME}" --icon=/usr/share/icons/pyradio.png --geometry "$POS" -e 'pyradio -lt'
|
||||
else
|
||||
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
|
||||
WIDTH=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/6]
|
||||
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
|
||||
LEFT=$[${WIDTH}*5-10]
|
||||
terminator -b -g "${TERM_CONFIG}" -T "${NAME}" --icon=/usr/share/icons/pyradio.png --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -e 'pyradio -lt'
|
||||
fi
|
||||
else
|
||||
ID_DEC=$((${ID}))
|
||||
ACTIVE_WIN_DEC=$(xdotool getactivewindow)
|
||||
if [ "${ACTIVE_WIN_DEC}" == "${ID_DEC}" ]; then
|
||||
xdotool windowminimize ${ID_DEC}
|
||||
else
|
||||
xdotool windowactivate ${ID_DEC}
|
||||
fi
|
||||
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
|
||||
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
__save() {
|
||||
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
|
||||
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
|
||||
}
|
||||
__reset() {
|
||||
rm -f $GEOMETRY_FILE
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
reset) __reset;;
|
||||
*) __run;;
|
||||
esac
|
45
bin/quake-term
Executable file
45
bin/quake-term
Executable file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Author: Daniel Napora <napcok@gmail.com> 2018-2024, https://maboxlinux.org
|
||||
# "Show-Hide" terminal wrapper for terminator for use with keybind eg. C-~ or F12.
|
||||
# Depenging on actual state it will start, show or hide terminal window.
|
||||
|
||||
GEOMETRY_FILE="$HOME/.config/.quake-term"
|
||||
NAME="Quake Term"
|
||||
|
||||
__run() {
|
||||
ID=$(wmctrl -x -l | grep "${NAME}" | awk '{print $1}' | head -n 1)
|
||||
if [ -z "${ID}" ]; then
|
||||
if [ -f "$GEOMETRY_FILE" ]; then
|
||||
POS=$(head -n 1 $GEOMETRY_FILE)
|
||||
terminator -T "${NAME}" -b --geometry "$POS" -i utilities-terminal
|
||||
else
|
||||
TOP=$(wmctrl -d|grep "*"|awk '{print $8}'|cut -d',' -f2)
|
||||
LEFT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f1)/8]
|
||||
HEIGHT=$[$(wmctrl -d|grep "*"|awk '{print $4}'|cut -d'x' -f2)/2]
|
||||
WIDTH=$[${LEFT}*6]
|
||||
terminator -T "${NAME}" -b --geometry "${WIDTH}x${HEIGHT}+${LEFT}+${TOP}" -i utilities-terminal
|
||||
fi
|
||||
else
|
||||
ID_DEC=$((${ID}))
|
||||
ACTIVE_WIN_DEC=$(xdotool getactivewindow)
|
||||
if [ "${ACTIVE_WIN_DEC}" == "${ID_DEC}" ]; then
|
||||
xdotool windowminimize ${ID_DEC}
|
||||
else
|
||||
xdotool windowactivate ${ID_DEC}
|
||||
fi
|
||||
eval $(xdotool getwindowgeometry --shell $(xdotool search --name "${NAME}"))
|
||||
echo "${WIDTH}x${HEIGHT}+${X}+${Y}" > $GEOMETRY_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
__reset() {
|
||||
rm "$GEOMETRY_FILE"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
reset) __reset;;
|
||||
*) __run;;
|
||||
esac
|
||||
|
||||
exit 0
|
56
bin/snapwin
56
bin/snapwin
@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
#: snapwin - click on the appropriate area of the window to snap it in a given direction.
|
||||
#: snapwin - click on the appropriate area of the window to snap it in a given direction.
|
||||
#: Works with active and inactive windows.
|
||||
#: Same actions are available for kebindings: topleft, top, topright, left, center, right,
|
||||
#: bottomleft, bottom and bottomright.
|
||||
# Copyright (C) Daniel Napora <napcok@gmail.com> 2021
|
||||
# Copyright (C) Daniel Napora <napcok@gmail.com> 2021-24
|
||||
# https://maboxlinux.org
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@ -56,40 +56,31 @@ GAP=${gap:-16}
|
||||
}
|
||||
|
||||
_movewin() {
|
||||
#notify-send.sh "Window: $WINDOW" "POS_CODE: $POS_CODE"
|
||||
WIDTH_FULL=$((AVAIL_X-OUT_GAP*2-BORDERCOMP_X))
|
||||
WIDTH_HALF=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X))
|
||||
WIDTH_SMALL=$((AVAIL_X/3-OUT_GAP-GAP/2-BORDERCOMP_X))
|
||||
WIDTH_WIDE=$((WIDTH_SMALL*2+GAP+BORDERCOMP_X))
|
||||
|
||||
HEIGHT_FULL=$((AVAIL_Y-OUT_GAP*2-BORDERCOMP_Y))
|
||||
HEIGHT_HALF=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2))
|
||||
|
||||
case $POS_CODE in
|
||||
00|"topleft") # top-left
|
||||
#echo "xdotool getwindowgeometry --shell $WINDOW"
|
||||
#eval xdotool getwindowgeometry --shell "$WINDOW"
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((OFF_X+OUT_GAP)) YPOS=$((OFF_Y+OUT_GAP));
|
||||
#echo -e "XPOS: $XPOS \nYPOS: $YPOS \nW: $W \nWINDOW $WINDOW"
|
||||
#echo "W+BORDERCOMP_X: $((W+BORDERCOMP_X))"
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE
|
||||
|
||||
;;&
|
||||
;;
|
||||
10|top) # top
|
||||
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((0+OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
|
||||
;;&
|
||||
;;
|
||||
20|topright) # top-right
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((OFF_Y+OUT_GAP))
|
||||
#eval xdotool getwindowgeometry --shell "$WINDOW"
|
||||
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
|
||||
# echo -e "XPOS: $XPOS \nYPOS: $YPOS \nW: $W \nWINDOW $WINDOW"
|
||||
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
|
||||
;;&
|
||||
;;
|
||||
01|left) # left
|
||||
#eval xdotool getwindowgeometry --shell "$WINDOW"
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((0+OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE;;
|
||||
@ -97,68 +88,50 @@ case $POS_CODE in
|
||||
HEIGHT_SMALL=$((AVAIL_Y/3-OUT_GAP-GAP/2-BORDERCOMP_Y))
|
||||
W=$WIDTH_FULL H=$HEIGHT_FULL XPOS=$((OFF_X+OUT_GAP)) YPOS=$((OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$WIDTH_FULL+BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
|
||||
;;&
|
||||
[[ "$X" -eq "$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((WIDTH_SMALL+BORDERCOMP_X))" ]] && W=$((AVAIL_X/10*8)) H=$((AVAIL_Y/10*8)) XPOS=$((AVAIL_X/10)) YPOS=$((AVAIL_Y/10))
|
||||
;;
|
||||
21|right) # right
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((0+OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
|
||||
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
|
||||
;;&
|
||||
;;
|
||||
02|bottomleft) # bottom-left
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W=$WIDTH_SMALL
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" ]] && W=$WIDTH_WIDE
|
||||
;;&
|
||||
;;
|
||||
12|bottom) # bottom
|
||||
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
|
||||
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
|
||||
;;&
|
||||
;;
|
||||
22|bottomright) # bottom-right
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
|
||||
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X));;&
|
||||
esac
|
||||
#notify-send.sh "$WINDOW $W $H" "$XPOS $YPOS"
|
||||
xdotool windowsize $WINDOW $W $H
|
||||
xdotool windowmove $WINDOW $XPOS $YPOS
|
||||
#echo "Po akcji =============="
|
||||
#eval xdotool getwindowgeometry --shell "$WINDOW"
|
||||
|
||||
|
||||
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi
|
||||
}
|
||||
_getwin() { #get active window (only when invoked by keyboard)
|
||||
_config
|
||||
WIN=$(xdotool getactivewindow)
|
||||
#echo "Win: $WIN"
|
||||
HEX_ID=$(printf '0x%x\n' $WIN)
|
||||
#echo $HEX_ID
|
||||
#####echo "$HEX_ID"
|
||||
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
|
||||
|
||||
WINDOW=$(xwininfo -id $(xdotool getactivewindow) -int -tree | awk '/^ *Parent/ {print $4}')
|
||||
#echo "WINDOW: $WINDOW"
|
||||
#WINDOW=$(xwininfo -id $WIN -int -tree | awk '/^ *Parent/ {print $4}')
|
||||
#WINDOW=$WIN
|
||||
winFRAME=$(xprop -id $WIN _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')
|
||||
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$winFRAME"
|
||||
#echo "winFRAME: $winFRAME"
|
||||
|
||||
BORDERCOMP_X=$((BORDER_L+BORDER_R))
|
||||
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
|
||||
eval $(xdotool getwindowgeometry --shell $WINDOW)
|
||||
#notify-send.sh -u critical "KEYS" "HEX_ID: $HEX_ID\nWINDOW $WINDOW\nwinFRAME: $winFRAME\nBORDERCOMP $BORDERCOMP_X $BORDERCOMP_Y \
|
||||
#X: $X\n \
|
||||
#Y: $Y\n \
|
||||
#WINDOW: $WINDOW\n \
|
||||
#WIDTH: $WIDTH\n \
|
||||
#HEIGHT: $HEIGHT"
|
||||
#echo "BORDERCOMP_X $BORDERCOMP_X"
|
||||
#echo "Przekazuję ID OKNA: $WINDOW"
|
||||
_movewin
|
||||
}
|
||||
|
||||
clicksnap() {
|
||||
_config
|
||||
#xdotool windowactivate $WINDOW
|
||||
### Clicksnap mouse action start
|
||||
eval $(xdotool getmouselocation --shell)
|
||||
Mouse_x="$X"
|
||||
@ -191,12 +164,6 @@ clicksnap() {
|
||||
BORDERCOMP_X=$((BORDER_L+BORDER_R))
|
||||
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
|
||||
|
||||
#notify-send.sh -u critical "Click" "WINDOW: $WINDOW\nHEX_ID: $HEX_ID\nCHILD_ID $CHILD_ID\nCHILD: $CHILD\nBORDERCOMP $BORDERCOMP_X $BORDERCOMP_Y \
|
||||
#X: $X\n \
|
||||
#Y: $Y\n \
|
||||
#WINDOW: $WINDOW\n \
|
||||
#WIDTH: $WIDTH\n \
|
||||
#HEIGHT: $HEIGHT"
|
||||
_movewin
|
||||
}
|
||||
|
||||
@ -214,5 +181,4 @@ case "$1" in
|
||||
"") clicksnap ;;
|
||||
topleft|top|topright|left|center|right|bottomleft|bottom|bottomright) moveto "$1" ;;
|
||||
-h|--help) usage ;;
|
||||
#*) moveto "$1";;
|
||||
esac
|
||||
|
177
bin/superclick
Executable file
177
bin/superclick
Executable file
@ -0,0 +1,177 @@
|
||||
#!/bin/bash
|
||||
#: superclick - click on the appropriate area of the window to snap it in a given direction.
|
||||
#: Works with active and inactive windows.
|
||||
#: Same actions are available for kebindings: topleft, top, topright, left, center, right,
|
||||
#: bottomleft, bottom and bottomright.
|
||||
# Copyright (C) Daniel Napora <napcok@gmail.com> 2021-24
|
||||
# https://maboxlinux.org
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
_config() {
|
||||
CONFIG_FILE="$HOME/.config/superclick.cfg"
|
||||
mkdir -p $CONFIG_DIR
|
||||
if [ ! -f $CONFIG_FILE ]; then
|
||||
cat <<EOF > ${CONFIG_FILE}
|
||||
# Gap between windows in pixels (reasonable values: 0 8 16 24)
|
||||
gap=16
|
||||
# Outer gap (disable if you use WM margins)
|
||||
show_outer_gap=true
|
||||
# Only for clicksnap (mouse) action
|
||||
activate_window=false
|
||||
EOF
|
||||
fi
|
||||
source <(grep = $CONFIG_FILE)
|
||||
GAP=${gap:-16}
|
||||
|
||||
## OUTER GAP
|
||||
if [[ "$show_outer_gap" == "true" ]]; then OUT_GAP=$((GAP/2)) ; else OUT_GAP="0" ; fi
|
||||
|
||||
OFFSET=$(wmctrl -d |grep "*" | awk -F' ' '{print $8}')
|
||||
REALSIZE=$(wmctrl -d |grep "*" | awk -F' ' '{print $9}')
|
||||
|
||||
AVAIL_X="${REALSIZE%x*}"
|
||||
AVAIL_Y="${REALSIZE#*x}"
|
||||
|
||||
OFF_X="${OFFSET%,*}"
|
||||
OFF_Y="${OFFSET#*,}"
|
||||
}
|
||||
|
||||
_movewin() {
|
||||
WIDTH_FULL=$((AVAIL_X-OUT_GAP*2-BORDERCOMP_X))
|
||||
WIDTH_HALF=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X))
|
||||
WIDTH_SMALL=$((AVAIL_X/3-OUT_GAP-GAP/2-BORDERCOMP_X))
|
||||
WIDTH_WIDE=$((WIDTH_SMALL*2+GAP+BORDERCOMP_X))
|
||||
HEIGHT_FULL=$((AVAIL_Y-OUT_GAP*2-BORDERCOMP_Y))
|
||||
HEIGHT_HALF=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2))
|
||||
|
||||
case $POS_CODE in
|
||||
00|"topleft") # top-left
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((OFF_X+OUT_GAP)) YPOS=$((OFF_Y+OUT_GAP));
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE
|
||||
|
||||
;;
|
||||
10|top) # top
|
||||
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((0+OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
|
||||
;;
|
||||
20|topright) # top-right
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((OFF_Y+OUT_GAP))
|
||||
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
|
||||
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_HALF+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
|
||||
;;
|
||||
01|left) # left
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((0+OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_SMALL
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE;;
|
||||
11|center) # center
|
||||
HEIGHT_SMALL=$((AVAIL_Y/3-OUT_GAP-GAP/2-BORDERCOMP_Y))
|
||||
W=$WIDTH_FULL H=$HEIGHT_FULL XPOS=$((OFF_X+OUT_GAP)) YPOS=$((OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$WIDTH_FULL+BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
|
||||
[[ "$X" -eq "$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((WIDTH_SMALL+BORDERCOMP_X))" ]] && W=$((AVAIL_X/10*8)) H=$((AVAIL_Y/10*8)) XPOS=$((AVAIL_X/10)) YPOS=$((AVAIL_Y/10))
|
||||
;;
|
||||
21|right) # right
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y-BORDERCOMP_Y-OUT_GAP*2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((0+OFF_Y+OUT_GAP))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
|
||||
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" && "$HEIGHT" -eq "$((HEIGHT_FULL+BORDERCOMP_Y))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X))
|
||||
;;
|
||||
02|bottomleft) # bottom-left
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W=$WIDTH_SMALL
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$WIDTH_HALF+BORDERCOMP_X" ]] && W=$WIDTH_WIDE
|
||||
;;
|
||||
12|bottom) # bottom
|
||||
W=$WIDTH_FULL H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((0+OFF_X+OUT_GAP)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
|
||||
[[ "$X" -eq "$XPOS" && "$WIDTH" -eq "$WIDTH_FULL+$BORDERCOMP_X" ]] && W=$WIDTH_SMALL XPOS=$((OFF_X+AVAIL_X/2-WIDTH_SMALL/2-BORDERCOMP_X/2))
|
||||
;;
|
||||
22|bottomright) # bottom-right
|
||||
W=$((AVAIL_X/2-OUT_GAP-GAP/2-BORDERCOMP_X)) H=$((AVAIL_Y/2-BORDERCOMP_Y-OUT_GAP-GAP/2)) XPOS=$((AVAIL_X/2+OFF_X+GAP/2)) YPOS=$((AVAIL_Y/2+OFF_Y+GAP/2))
|
||||
[[ "$X" -eq "$XPOS" && "$Y" -eq "$YPOS" && "$WIDTH" -eq "$((W+BORDERCOMP_X))" ]] && W="$WIDTH_SMALL" XPOS=$((OFF_X+AVAIL_X-WIDTH_SMALL-OUT_GAP-BORDERCOMP_X))
|
||||
[[ "$X" -eq "$((AVAIL_X-WIDTH_SMALL+OFF_X-OUT_GAP-BORDERCOMP_X))" && "$Y" -eq "$YPOS" && "$WIDTH" -lt "$((WIDTH_HALF+BORDERCOMP_X))" ]] && W=$WIDTH_WIDE XPOS=$((AVAIL_X-WIDTH_WIDE+OFF_X-OUT_GAP-BORDERCOMP_X));;&
|
||||
esac
|
||||
xdotool windowsize $WINDOW $W $H
|
||||
xdotool windowmove $WINDOW $XPOS $YPOS
|
||||
|
||||
if [ $activate_window == "true" ]; then xdotool windowactivate $WINDOW; fi
|
||||
}
|
||||
_getwin() { #get active window (only when invoked by keyboard)
|
||||
_config
|
||||
WIN=$(xdotool getactivewindow)
|
||||
HEX_ID=$(printf '0x%x\n' $WIN)
|
||||
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
|
||||
|
||||
WINDOW=$(xwininfo -id $(xdotool getactivewindow) -int -tree | awk '/^ *Parent/ {print $4}')
|
||||
winFRAME=$(xprop -id $WIN _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')
|
||||
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$winFRAME"
|
||||
|
||||
BORDERCOMP_X=$((BORDER_L+BORDER_R))
|
||||
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
|
||||
eval $(xdotool getwindowgeometry --shell $WINDOW)
|
||||
_movewin
|
||||
}
|
||||
|
||||
clicksnap() {
|
||||
_config
|
||||
### Clicksnap mouse action start
|
||||
eval $(xdotool getmouselocation --shell)
|
||||
Mouse_x="$X"
|
||||
Mouse_y="$Y"
|
||||
|
||||
HEX_ID=$(printf '0x%x\n' $WINDOW)
|
||||
wmctrl -i -r $HEX_ID -b remove,maximized_vert,maximized_horz
|
||||
CHILD_ID=$(xwininfo -id $HEX_ID -children|grep "\"" | awk '{print $1}')
|
||||
if xwininfo -id $CHILD_ID -wm |grep Dock ; then exit 0 ;fi # Ignore Dock eg. tint2
|
||||
|
||||
eval $(xdotool getwindowgeometry --shell $WINDOW)
|
||||
Win_x="$X"
|
||||
Win_y="$Y"
|
||||
Win_width="$WIDTH"
|
||||
Win_height="$HEIGHT"
|
||||
|
||||
if [[ $Mouse_x -gt $Win_x && $Mouse_x -lt $((Win_x+WIDTH)) && $Mouse_y -gt $Win_y && $Mouse_y -lt $((Win_y+HEIGHT)) ]];then
|
||||
pos_x="$(((Mouse_x-Win_x)/(Win_width/3)))"
|
||||
pos_y="$(((Mouse_y-Win_y)/(Win_height/3)))"
|
||||
POS_CODE="$pos_x$pos_y"
|
||||
else
|
||||
pos_x="$((Mouse_x*3/AVAIL_X))"
|
||||
pos_y="$((Mouse_y*3/AVAIL_Y))"
|
||||
POS_CODE="$pos_x$pos_y"
|
||||
fi
|
||||
|
||||
CHILD=$(printf %i $CHILD_ID)
|
||||
read BORDER_L BORDER_R BORDER_T BORDER_B <<< "$(xprop -id $CHILD _NET_FRAME_EXTENTS | awk ' {gsub(/,/,"");print $3,$4,$5,$6}')"
|
||||
|
||||
BORDERCOMP_X=$((BORDER_L+BORDER_R))
|
||||
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
|
||||
|
||||
_movewin
|
||||
}
|
||||
|
||||
moveto() {
|
||||
POS_CODE="$1"
|
||||
_getwin
|
||||
|
||||
}
|
||||
usage() {
|
||||
grep "^#:" $0 | while read DOC; do printf '%s\n' "${DOC###:}"; done
|
||||
exit
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"") clicksnap ;;
|
||||
topleft|top|topright|left|center|right|bottomleft|bottom|bottomright) moveto "$1" ;;
|
||||
-h|--help) usage ;;
|
||||
esac
|
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.4 KiB |
@ -47,7 +47,7 @@ left: 50%;
|
||||
<div class="item2">↑</div>
|
||||
<div class="item3">↗</div>
|
||||
<div class="item4">←</div>
|
||||
<div class="item5"><span><br />hold <kbd>Ctrl+Shift</kbd><br />and click<br />in appropriate area<br />of any window</span></div>
|
||||
<div class="item5"><span><br />hold <kbd>Super</kbd> key<br />and click<br />in appropriate area<br />of any window</span></div>
|
||||
<div class="item6">→</div>
|
||||
<div class="item7">↙</div>
|
||||
<div class="item8">↓</div>
|
||||
|
Loading…
Reference in New Issue
Block a user