deskgrid, deskmngr update

master
Daniel Napora 2022-02-12 23:19:13 +01:00
parent 64668524da
commit afce9e0ebc
3 changed files with 22 additions and 13 deletions

View File

@ -96,7 +96,7 @@ if [[ $start_y = "0" ]]; then GAP_Y="$((GAP*GF))" ; else GAP_Y=$((GAP/2)) ; fi
if [[ $end_x = $((COLUMNS-1)) ]]; then GAP_X_END="$((GAP/2))" ; else GAP_X_END=$((GAP/2)) ; fi
if [[ $end_y = $((ROWS-1)) ]]; then GAP_Y_END="$((GAP/2))" ; else GAP_Y_END=$((GAP/2)) ; fi
SIZE="$(((end_x-start_x+1)*(AVAIL_X/COLUMNS)-GAP_X/2-GAP_X_END)) $(((end_y-start_y+1)*(AVAIL_Y/ROWS)-GAP_Y/2-GAP_Y_END-BORDERCOMP_Y))"
SIZE="$(((end_x-start_x+1)*(AVAIL_X/COLUMNS)-GAP_X/2-GAP_X_END-BORDERCOMP_X)) $(((end_y-start_y+1)*(AVAIL_Y/ROWS)-GAP_Y/2-GAP_Y_END-BORDERCOMP_Y))"
POSITION="$((start_x*AVAIL_X/COLUMNS+GAP_X/2+MARGIN_X)) $((start_y*AVAIL_Y/ROWS+GAP_Y/2+MARGIN_Y))"

View File

@ -1,5 +1,6 @@
#!/bin/bash
# Copyright (C) Daniel Napora 2021 <napcok@gmail.com>
# Copyright (C) Daniel Napora 2021-22 <napcok@gmail.com>
# https://maboxlinux.org
#: deskmngr - save all programs (windows) running on current desktop in session file.
#: With windows positions and state (decorated or not)
#: Usage:
@ -21,8 +22,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
SESSIONDIR="$HOME/.config/deskmngr/"
CONFIG_FILE="$SESSIONDIR/deskmngr.conf"
mkdir -p $SESSIONDIR
# If config file not exist create one with defaults
if [ ! -f $CONFIG_FILE ]; then
cat <<EOF > ${CONFIG_FILE}
waitsec=1
EOF
fi
source <(grep = $CONFIG_FILE)
waittime=${waitsec:-1}
case "$LANG" in
pl*)
TITLE="Nie ma nic do zapisania"
@ -106,13 +116,12 @@ restoresession() {
do
read -r D width height x y cmdline< <(echo $line)
wmctrl -s ${DESK}
${cmdline} > /dev/null 2>&1 &
sleep 5
${cmdline} > /dev/null 2>&1 &
# We need to wait for window to appear
sleep ${waittime}
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
if [[ "$D" = "u" ]]; then xdotool key super+b; fi
wmctrl -r :ACTIVE: -e 0,${x},${y},${width},${height}
done
}
}

View File

@ -69,7 +69,7 @@ _movewin() {
#echo "Width WIDE: $WIDTH_WIDE"
case $POS_CODE in
00|topleft) # top-left
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));
@ -131,23 +131,23 @@ 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"
#echo "Win: $WIN"
HEX_ID=$(printf '0x%x\n' $WIN)
echo $HEX_ID
#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"
#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"
#echo "winFRAME: $winFRAME"
BORDERCOMP_X=$((BORDER_L+BORDER_R))
BORDERCOMP_Y=$((BORDER_T+BORDER_B))
echo "BORDERCOMP_X $BORDERCOMP_X"
echo "Przekazuję ID OKNA: $WINDOW"
#echo "BORDERCOMP_X $BORDERCOMP_X"
#echo "Przekazuję ID OKNA: $WINDOW"
_movewin
}