Stickyjwm and Stickyxfce-- Control Windows

Moderator: Forum moderators

Post Reply
User avatar
mikeslr
Posts: 2951
Joined: Mon Jul 13, 2020 11:08 pm
Has thanked: 178 times
Been thanked: 909 times

Stickyjwm and Stickyxfce-- Control Windows

Post by mikeslr »

Discussion of Stickyxfce begins here, viewtopic.php?p=56582#p56582

recobayu developed stickyjwm for Puppies, http://murga-linux.com/puppy/viewtopic. ... 498#825498. That two page thread will provide links to pets for Tahrpup and Xenialpup, perhaps earlier (Ubuntu based?) puppies. A pet for bionicpup and fossapup64 can be found here: viewtopic.php?p=6342#p6342. From recobayu's posts I think it is based on MochiMoppel's work. It uses "Ctrl + Alt + Arrow to move window to up, left, down, and right side of screen".

wmctrl is a dependency which is likely already on your system. As I understand it, stickyjwm can be used to "to make windows full-screen, always-above or sticky, and to activate, close, move, resize, maximize and minimize them."

Screenshots:viewtopic.php?p=6342#p6342, http://murga-linux.com/puppy/viewtopic. ... 72#1017372.

Current usage commands from the above link:
"win + arrow = stickyjwm
win + shift + arrow = maxleft, maxright, etc (default sticky by jwm)
win + alt + arrow = resize window per 100px"

Puppus Dogfellow published another tool named windowplacementpack. See, http://murga-linux.com/puppy/viewtopic. ... 860#796860 and the post following it. But also read, http://murga-linux.com/puppy/viewtopic. ... 655#797655. Screenshot of implementation:

windowplacementpack.png
windowplacementpack.png (254.44 KiB) Viewed 4208 times

Sorry. I haven't used either of these. Just recording their existence for those who might be interested.

Last edited by mikeslr on Mon May 09, 2022 2:11 pm, edited 1 time in total.
User avatar
gychang
Posts: 591
Joined: Fri Aug 28, 2020 4:51 pm
Location: San Diego, CA
Has thanked: 206 times
Been thanked: 64 times

Re: Stickyjwm -- Control aspects of application windows

Post by gychang »

can stickyjwm move an active window to 4 corners of the display using keyboard command?.

On my Bionicpup64, I can move to R/L half of screen with by adding below to jwmrc-personal with
"<Key mask="4" key="Left">maxleft</Key>
<Key mask="4" key="Right">maxright</Key>"

Can stickyjwm allow keyboard control to move e.g xterm to right-upper 1/4 of the screen display?

I was able to figure out by downloading stickyjwm-4.1.pet file and combining with my .jwmrc-personal file...

======

Puppy Bytes, utube videos
https://www.youtube.com/channel/UCg-DUU ... u62_iqR-MA

======

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

gychang wrote: Tue Feb 23, 2021 6:52 am

can stickyjwm move an active window to 4 corners of the display using keyboard command?.

On my Bionicpup64, I can move to R/L half of screen with by adding below to jwmrc-personal with
"<Key mask="4" key="Left">maxleft</Key>
<Key mask="4" key="Right">maxright</Key>"

Can stickyjwm allow keyboard control to move e.g xterm to right-upper 1/4 of the screen display?

I was able to figure out by downloading stickyjwm-4.1.pet file and combining with my .jwmrc-personal file...

Yes of course. With stickyjwm, we can play like in linux mint cinnamon. please go here (the last post: stickyjwm-19.1) if you use bionicpup32:
https://oldforum.puppylinux.com/viewtop ... 2#p1017372
or you can here if you use bionicpup64 of fossapup64:
viewtopic.php?p=6342#p6342

Last edited by recobayu on Sat Jul 10, 2021 6:01 am, edited 1 time in total.
User avatar
MochiMoppel
Posts: 1229
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 21 times
Been thanked: 436 times

Re: Stickyjwm -- Control aspects of application windows

Post by MochiMoppel »

recobayu wrote: Sat Jul 10, 2021 3:14 am

or you can here if you use bionicpup64 of fossapup64:
viewtopic.php?p=6342#p6342

@recobayu I don't know if Stickyjwm can shift a window, maintaining its current dimension, to the 4 corners - I assume it can. If so does it work in the 64bit flavors for undecorated windows, e.g. for windows without a title bar and without borders?

I'm asking because I noticed a bug in xwininfo, which you probably use for calculating the window location.
In Slacko8 and AFAIR also in Fossapup64 xwininfo doesn't get the relative positions of undecorated windows right, so that windows might always end up in position 0,0 (upper left corner)

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

MochiMoppel wrote: Sat Jul 10, 2021 4:32 am
recobayu wrote: Sat Jul 10, 2021 3:14 am

or you can here if you use bionicpup64 of fossapup64:
viewtopic.php?p=6342#p6342

@recobayu I don't know if Stickyjwm can shift a window, maintaining its current dimension, to the 4 corners - I assume it can. If so does it work in the 64bit flavors for undecorated windows, e.g. for windows without a title bar and without borders?

I'm asking because I noticed a bug in xwininfo, which you probably use for calculating the window location.
In Slacko8 and AFAIR also in Fossapup64 xwininfo doesn't get the relative positions of undecorated windows right, so that windows might always end up in position 0,0 (upper left corner)

Hi @MochiMoppel. In my script, I don't maintaining the current dimension when it window unsticky. It always do a half / quarter of screen. But for undecorated windows, stickyjwm also can handle it. In this example, I set titlebar=5 and border=5.

Attachments
Screenshot(1).png
Screenshot(1).png (230.18 KiB) Viewed 4084 times
recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

Hi Mochimoppel,
I just try slacko8.2.1.
The problem is in this puppy, there is no wmctrl. So I download wmctrl from here:
https://packages.slackonly.com/pub/pack ... slonly.txz
because there is no wmctrl in ppm
and after that, I success do stickyjwm. Also using win+alt+right is okay.

here is the screenshot:

edit:
it's weird with screenshots on slacko. when i upload using attachment, the image is not correct. just vertical lines. So I put the image on ibb.co

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

Hi All.
I make this update of stickyjwm.
Now, it can surf our entire monitor.
I try using 3 monitors, and it runs well.
It can detect our connected monitor and our active monitor

In the linux mint, using winkey + arrow, the window only snap on the current monitor, if we want to teleport into another monitor, we use another shortcut.
In the windows 10, we do not get the 2 or 8 position (2 means tophalf, and 8 means bottomhalf, look at the code for the ilustration of the position window)
But using this code, we can feel the advantage of both (linux mint cinnamon and windows 10) snap window on our puppy linux or debiandog.

Image

And also, I simplify the code into one file.
Here is the code:

Code: Select all

#!/bin/bash

# 220321 partition screen into three height (h1 and h2 line as border)
#        and three width (w1 and w2 line as border)
# 220503 add margins

wd=`echo /tmp$HOME/.stickyjwm`
#echo "$wd"
#rm -r "$wd"
mkdir -p "$wd"

case "$1" in
	-h|--help) echo ' usage:
	-up 	: snap to top monitor
	-left 	: snap to left monitor
	-down 	: snap to bottom monitor
	-right 	: snap to right monitor'
esac

margin_top=0
margin_left=0
margin_bottom=30
margin_right=0

# list all active monitors and sort it by x coordinate
xrandr --listactivemonitors|grep x|awk -F '[ +x/]' '{print $4,$5-'$margin_left'-'$margin_right',$7-'$margin_top'-'$margin_bottom',$9+'$margin_left',$10+'$margin_top'}'|sed 's/*//g'|sort -k4,4n > "$wd"/monitors-active

# debug
# name	w	h	x	y of monitor
#	0	1	2	3	4



## Get window position information
if [ ! -d "$wd"/info ];then mkdir -p "$wd"/info; fi
id_window=$(xprop -root|awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')
xwininfo -id $id_window>"$wd"/info/$id_window
w_window=`awk '/Width/{print $2}' "$wd"/info/$id_window`
h_window=`awk '/Height/{print $2}' "$wd"/info/$id_window`
x_window=`awk '/Absolute upper-left X/{print $4}' "$wd"/info/$id_window`
y_window=`awk '/Absolute upper-left Y/{print $4}' "$wd"/info/$id_window`
border=`awk '/Relative upper-left X/{print $4}' "$wd"/info/$id_window`
title=`awk '/Relative upper-left Y/{print $4}' "$wd"/info/$id_window`

# got the center coordinate of window
cx_window=$(( $x_window + $w_window / 2 ))
cy_window=$(( $y_window + $h_window / 2 ))


# check if there is a config file for this window.
if [ ! -f "$wd/$id_window" ];then		#if not found, then make it!


	while read line;do
		mntr=($line)
		
		#echo "${mntr[@]}"
		
		w_plus_x=$(( ${mntr[1]} + ${mntr[3]} ))
		#echo w_plus_x = "$w_plus_x"

		#echo "$x_window" "$w_plus_x"
		if [ "$x_window" -lt "$w_plus_x" ];then
			#echo "the window is on ${mntr[0]}"
			current=(${mntr[@]})
			echo "${current[@]}" > "$wd/$id_window"
			break
		#else
			#echo "the window is on the right of $mntr"
		fi
	done < "$wd"/monitors-active

else
	#echo "take from config file in $wd/$id_window"
	current=(`cat $wd/$id_window`)
fi
#echo "Selesai"
#echo current monitor: "${current[@]}"
echo

# set the margin into current monitor config
#current[1]=$(( ${current[1]} - $margin_left - $margin_right ))
#current[2]=$(( ${current[2]} - $margin_top - $margin_bottom ))
#current[3]=$(( ${current[3]} + $margin_left ))
#current[4]=$(( ${current[4]} + $margin_top ))

goto_left_monitor(){
	left=(`grep -B 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#left[@]} -eq 0 ];then left=(`tail -1 "$wd"/monitors-active`); fi
	echo ${left[@]} > "$wd/$id_window"
	current=(${left[@]})
}

goto_right_monitor(){
	right=(`grep -A 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#right[@]} -eq 0 ];then right=(`head -1 "$wd"/monitors-active`); fi
	echo ${right[@]} > "$wd/$id_window"
	current=(${right[@]})
}



# position window on monitor
# 1 | 2 | 3
#----------- h1
# 4 | 5 | 6
#----------- h2
# 7 | 8 | 9
#   w1  w2


w1=$(( ${current[3]} + ${current[1]} / 3 ))
w2=$(( ${current[3]} + ${current[1]} / 3 * 2))
h1=$(( ${current[4]} + ${current[2]} / 3 ))
h2=$(( ${current[4]} + ${current[2]} / 3 * 2))

echo cx:$cx_window, w: $w1, $w2, $(( ${current[1]} + ${current[3]} ))
echo cy:$cy_window, h: $h1, $h2, $(( ${current[2]} + ${current[4]} ))





# result
pos1(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos1 on ${current[0]}
}

pos2(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos2 on ${current[0]}
}

pos3(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos3 on ${current[0]}
}

pos4(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos4 on ${current[0]}
}

pos5(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=${current[2]}
	echo pos5 on ${current[0]}
}

pos6(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos6 on ${current[0]}
}

pos7(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos7 on ${current[0]}
}

pos8(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos8 on ${current[0]}
}

pos9(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos9 on ${current[0]}
}

center(){
	margin=150
	x=$(( ${current[3]} + $margin ))
	y=$(( ${current[4]} + $margin / 2 ))
	w=$(( ${current[1]} - 2 * $margin ))
	h=$(( ${current[2]} - $margin ))
	echo center on ${current[0]}
}




# check, where is this window position (1 - 9)
if [ $cy_window -lt $h1 ];then
	echo top of h1: 1, 2, 3
	if [ $cx_window -lt $w1 ];then
		echo 1
		case $1 in
			-up) goto_left_monitor; pos7;;
			-right) pos2;;
			-down) pos4;;
			-left) goto_left_monitor; pos3;;
			*) pos2;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 2
		case $1 in
			-up) pos5;;
			-right) pos3;;
			-down) center;;
			-left) pos1;;
			*) pos3;;
		esac
	else
		echo 3
		case $1 in
			-up) goto_left_monitor; pos9;;
			-right) goto_right_monitor; pos1;;
			-down) pos6;;
			-left) pos2;;
			*) goto_right_monitor; pos1;;
		esac
	fi
	
elif [ $cy_window -lt $h2 ];then
	echo between h1 and h2: 4, 5, 6
	if [ $cx_window -lt $w1 ];then
		echo 4
		case $1 in
			-up) pos1;;
			-right) center;;
			-down) pos7;;
			-left) goto_left_monitor; pos6;;
			*) center;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 5
		case $1 in
			-up) pos2;;
			-right) pos6;;
			-down) pos8;;
			-left) pos4;;
			*) pos6;;
		esac
	else
		echo 6
		case $1 in
			-up) pos3;;
			-right) goto_right_monitor; pos4;;
			-down) pos9;;
			-left) center;;
			*) goto_right_monitor; pos4;;
		esac
	fi
else
	echo bottom of h2: 7, 8, 9
	if [ $cx_window -lt $w1 ];then
		echo 7
		case $1 in
			-up) pos4;;
			-right) pos8;;
			-down) goto_right_monitor; pos1;;
			-left) goto_left_monitor; pos9;;
			*) pos8;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 8
		case $1 in
			-up) center;;
			-right) pos9;;
			-down) goto_right_monitor; pos2;;
			-left) pos7;;
			*) pos9;;
		esac
	else
		echo 9
		case $1 in
			-up) pos6;;
			-right) goto_right_monitor; pos7;;
			-down) goto_right_monitor; pos3;;
			-left) pos8;;
			*) goto_right_monitor; pos7;;
		esac
	fi
fi



# set up for border and decoration
w=$(( $w - 2*$border ))
h=$(( $h - $title - $border ))
echo x,y,w,h now
echo $x,$y,$w,$h


# run twice to make terminal better place
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
wmctrl -r :ACTIVE: -e 1,$x,$y,$w,$h

But in this code,
I still do not include the calculation of the tray yet.

Don't forget to add this shortcut on our /root/.jwmrc (or we can "Include" it from another <JWM> xml code.

Code: Select all

<Key mask="4" key="Up">exec:stickyjwm -up</Key>
<Key mask="4" key="Left">exec:stickyjwm -left</Key>
<Key mask="4" key="Down">exec:stickyjwm -down</Key>
<Key mask="4" key="Right">exec:stickyjwm -right</Key>

Feel free to use and improve this code on woof-ce.
Thank you. :)

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

this script work on xfce
I change on line 36:

Code: Select all

id_window=$(xprop -root|awk -F'[ ,]' '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $5}')

stickyjwm-xfce or stickyxfce

Code: Select all

#!/bin/bash

# 220321 partition screen into three height (h1 and h2 line as border)
#        and three width (w1 and w2 line as border)
# 220503 add margins

wd=`echo /tmp$HOME/.stickyjwm`
#echo "$wd"
#rm -r "$wd"
mkdir -p "$wd"

case "$1" in
	-h|--help) echo ' usage:
	-up 	: snap to top monitor
	-left 	: snap to left monitor
	-down 	: snap to bottom monitor
	-right 	: snap to right monitor'
esac

margin_top=0
margin_left=0
margin_bottom=0
margin_right=0

# list all active monitors and sort it by x coordinate
xrandr --listactivemonitors|grep x|awk -F '[ +x/]' '{print $4,$5-'$margin_left'-'$margin_right',$7-'$margin_top'-'$margin_bottom',$9+'$margin_left',$10+'$margin_top'}'|sed 's/*//g'|sort -k4,4n > "$wd"/monitors-active

# debug
# name	w	h	x	y of monitor
#	0	1	2	3	4



## Get window position information
if [ ! -d "$wd"/info ];then mkdir -p "$wd"/info; fi
id_window=$(xprop -root|awk -F'[ ,]' '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $5}')
xwininfo -id $id_window>"$wd"/info/$id_window
w_window=`awk '/Width/{print $2}' "$wd"/info/$id_window`
h_window=`awk '/Height/{print $2}' "$wd"/info/$id_window`
x_window=`awk '/Absolute upper-left X/{print $4}' "$wd"/info/$id_window`
y_window=`awk '/Absolute upper-left Y/{print $4}' "$wd"/info/$id_window`
border=`awk '/Relative upper-left X/{print $4}' "$wd"/info/$id_window`
title=`awk '/Relative upper-left Y/{print $4}' "$wd"/info/$id_window`

# got the center coordinate of window
cx_window=$(( $x_window + $w_window / 2 ))
cy_window=$(( $y_window + $h_window / 2 ))


# check if there is a config file for this window.
if [ ! -f "$wd/$id_window" ];then		#if not found, then make it!


	while read line;do
		mntr=($line)
		
		#echo "${mntr[@]}"
		
		w_plus_x=$(( ${mntr[1]} + ${mntr[3]} ))
		#echo w_plus_x = "$w_plus_x"

		#echo "$x_window" "$w_plus_x"
		if [ "$x_window" -lt "$w_plus_x" ];then
			#echo "the window is on ${mntr[0]}"
			current=(${mntr[@]})
			echo "${current[@]}" > "$wd/$id_window"
			break
		#else
			#echo "the window is on the right of $mntr"
		fi
	done < "$wd"/monitors-active

else
	#echo "take from config file in $wd/$id_window"
	current=(`cat $wd/$id_window`)
fi
#echo "Selesai"
#echo current monitor: "${current[@]}"
echo

# set the margin into current monitor config
#current[1]=$(( ${current[1]} - $margin_left - $margin_right ))
#current[2]=$(( ${current[2]} - $margin_top - $margin_bottom ))
#current[3]=$(( ${current[3]} + $margin_left ))
#current[4]=$(( ${current[4]} + $margin_top ))

goto_left_monitor(){
	left=(`grep -B 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#left[@]} -eq 0 ];then left=(`tail -1 "$wd"/monitors-active`); fi
	echo ${left[@]} > "$wd/$id_window"
	current=(${left[@]})
}

goto_right_monitor(){
	right=(`grep -A 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#right[@]} -eq 0 ];then right=(`head -1 "$wd"/monitors-active`); fi
	echo ${right[@]} > "$wd/$id_window"
	current=(${right[@]})
}



# position window on monitor
# 1 | 2 | 3
#----------- h1
# 4 | 5 | 6
#----------- h2
# 7 | 8 | 9
#   w1  w2


w1=$(( ${current[3]} + ${current[1]} / 3 ))
w2=$(( ${current[3]} + ${current[1]} / 3 * 2))
h1=$(( ${current[4]} + ${current[2]} / 3 ))
h2=$(( ${current[4]} + ${current[2]} / 3 * 2))

echo cx:$cx_window, w: $w1, $w2, $(( ${current[1]} + ${current[3]} ))
echo cy:$cy_window, h: $h1, $h2, $(( ${current[2]} + ${current[4]} ))





# result
pos1(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos1 on ${current[0]}
}

pos2(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos2 on ${current[0]}
}

pos3(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos3 on ${current[0]}
}

pos4(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos4 on ${current[0]}
}

pos5(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=${current[2]}
	echo pos5 on ${current[0]}
}

pos6(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos6 on ${current[0]}
}

pos7(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos7 on ${current[0]}
}

pos8(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos8 on ${current[0]}
}

pos9(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos9 on ${current[0]}
}

center(){
	margin=150
	x=$(( ${current[3]} + $margin ))
	y=$(( ${current[4]} + $margin / 2 ))
	w=$(( ${current[1]} - 2 * $margin ))
	h=$(( ${current[2]} - $margin ))
	echo center on ${current[0]}
}




# check, where is this window position (1 - 9)
if [ $cy_window -lt $h1 ];then
	echo top of h1: 1, 2, 3
	if [ $cx_window -lt $w1 ];then
		echo 1
		case $1 in
			-up) goto_left_monitor; pos7;;
			-right) pos2;;
			-down) pos4;;
			-left) goto_left_monitor; pos3;;
			*) pos2;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 2
		case $1 in
			-up) pos5;;
			-right) pos3;;
			-down) center;;
			-left) pos1;;
			*) pos3;;
		esac
	else
		echo 3
		case $1 in
			-up) goto_left_monitor; pos9;;
			-right) goto_right_monitor; pos1;;
			-down) pos6;;
			-left) pos2;;
			*) goto_right_monitor; pos1;;
		esac
	fi
	
elif [ $cy_window -lt $h2 ];then
	echo between h1 and h2: 4, 5, 6
	if [ $cx_window -lt $w1 ];then
		echo 4
		case $1 in
			-up) pos1;;
			-right) center;;
			-down) pos7;;
			-left) goto_left_monitor; pos6;;
			*) center;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 5
		case $1 in
			-up) pos2;;
			-right) pos6;;
			-down) pos8;;
			-left) pos4;;
			*) pos6;;
		esac
	else
		echo 6
		case $1 in
			-up) pos3;;
			-right) goto_right_monitor; pos4;;
			-down) pos9;;
			-left) center;;
			*) goto_right_monitor; pos4;;
		esac
	fi
else
	echo bottom of h2: 7, 8, 9
	if [ $cx_window -lt $w1 ];then
		echo 7
		case $1 in
			-up) pos4;;
			-right) pos8;;
			-down) goto_right_monitor; pos1;;
			-left) goto_left_monitor; pos9;;
			*) pos8;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 8
		case $1 in
			-up) center;;
			-right) pos9;;
			-down) goto_right_monitor; pos2;;
			-left) pos7;;
			*) pos9;;
		esac
	else
		echo 9
		case $1 in
			-up) pos6;;
			-right) goto_right_monitor; pos7;;
			-down) goto_right_monitor; pos3;;
			-left) pos8;;
			*) goto_right_monitor; pos7;;
		esac
	fi
fi



# set up for border and decoration
w=$(( $w - 2*$border ))
h=$(( $h - $title - $border ))
echo x,y,w,h now
echo $x,$y,$w,$h


# run twice to make terminal better place
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
wmctrl -r :ACTIVE: -e 1,$x,$y,$w,$h

put it on /usr/bin
then add shortcut to it.
stickyxfce -right
stickyxfce -up
stickyxfce -left
stickyxfce -down

assign to win+right, win+up, win+left, and win+down arrow.

User avatar
rockedge
Site Admin
Posts: 6524
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2736 times
Been thanked: 2615 times
Contact:

Re: Stickyjwm -- Control aspects of application windows

Post by rockedge »

I am adding it in to KLV-Airedale for testing. Once I started using it, it became indispensable.

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

@rockedge, the variables:
margin_top=0
margin_left=0
margin_bottom=0
margin_right=0
Can be change manually. It is very good if you can make the gui configuration using gtkdialog to change that.
Thank you very much

User avatar
rockedge
Site Admin
Posts: 6524
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2736 times
Been thanked: 2615 times
Contact:

Re: Stickyjwm -- Control aspects of application windows

Post by rockedge »

@recobayu Here is stickyxfce working on KLV-Airedale-beta14. I will install it to the KLV_rootfs for beta15.
Set the keyboard bindings to <Super>+Up, <Super>+Down, <Super>+Left, <Super>+Right using the GUI editor to add the bindings to /usr/local/bin/stickyxfce by using the menu: Applications->Settings->Keyboard->Application Shortcuts

Image

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

Thank you, @rockedge..
It seems that the bottom tray covers the window. You can set the margin_bottom variable in the stickyxfce script manually to make it better.

If you have three or more monitors, try stickyxfce to make the window play around the monitors.

Question:
How did you make the gif animation like that?
I like it. It is more easy to understand than just a picture.

User avatar
Grey
Posts: 2023
Joined: Wed Jul 22, 2020 12:33 am
Location: Russia
Has thanked: 76 times
Been thanked: 376 times

Re: Stickyjwm -- Control aspects of application windows

Post by Grey »

recobayu wrote: Tue Mar 01, 2022 5:44 pm

I make this update of stickyjwm.

In the linux mint,

Yes, it is really convenient. And there is even a window centering. Mint stands aside and nervously smokes looking at Fossapup :)

Thanks, great job :thumbup:

Fossapup OS, Ryzen 5 3600 CPU, 64 GB RAM, GeForce GTX 1050 Ti 4 GB, Sound Blaster Audigy Rx with amplifier + Yamaha speakers for loud sound, USB Sound Blaster X-Fi Surround 5.1 Pro V3 + headphones for quiet sound.

User avatar
wiak
Posts: 4074
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1204 times
Contact:

Re: Stickyjwm -- Control aspects of application windows

Post by wiak »

Posted XFCE "Window Manager" related comment to following thread, since an alternative for KLV and don't want to imply can replace stickyxfce - as I say, both could be useful in KLV-Airedale probably:

viewtopic.php?p=56935#p56935

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm -- Control aspects of application windows

Post by recobayu »

Thank you, @wiak..
Using stickyxfce, we can make different position using the same shortcut/keybinding. Eventough multi monitor.

Yes, i also sometimes use default keybinds of xfce to snap window to 9 positions using this keybinds:
Win+u : top left
Win+i : top half
Win+o : top right

Win+j : left half
Win+k : maximize
Win+l : right half

Win+m : bottom left
Win+, : bottom half
Win+. : bottom right

Because the position of
u , i , o
j , k , l
m , , , .
are easy to click using right hand
And to teleport to next/previous monitor, using shift+win+right/left arrow.

But once again, using stickyxfce, we can use the same keybind, example: stickyxfce -right to snap window to position 1, 2, 3, eventough teleport to next monitors.

;)

User avatar
wiak
Posts: 4074
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 65 times
Been thanked: 1204 times
Contact:

Re: Stickyjwm -- Control aspects of application windows

Post by wiak »

Yes, I can understand how powerful stickyxfce can be. Standard xfce window manager keyboarding is simple but limited, and no use for multi-monitor functionality as far as I know. I'm planning to adopt stickyxfce overall too. Thanks for the work.

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

User avatar
MochiMoppel
Posts: 1229
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 21 times
Been thanked: 436 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by MochiMoppel »

@recobayu Works in EasyOS ... sort of.
The old problem remains: Windows slide under trays. Particularly annoying in case of top trays because this can hide the title bars.

I checked my old scripts I once did for Puppus to see how I solved the problem. Well, I cheated and added tray margins manually into the script. As you may already know, programmatically retrieving the values from .jwmrc is VERY tricky and almost impossible. Even manually looking the values up can be hard. And there can be multiple trays, stacked or side by side... unlimited ways to make calculation a nightmare.

I've now come up with what may be a simple solution. It uses the fact that windows, maximized by the WM (or by wmctrl !), do not cover trays or slide under them . This means that we can measure the dimensions of a maximized window and the dimensions of the screen. Any difference is caused by trays,which gives us the tray margins.

This little script creates a tiny (1x1px) test window (to keep the flicker low), waits 0.3sec. to finish the creation, then maximizes it, measures geometry, then closes the window. May be enough to run it once a session and write values to config file. No idea how this works out with multiple monitors.

Code: Select all

#!/bin/bash

## Read current screen dimension
ARRAY=($(xwininfo -root))
SCREEN_W=${ARRAY[27]}
SCREEN_H=${ARRAY[29]}

## Create 1px test window (no focus, no decoration, layer below, skip taskbar)
echo '<window title="@@" type-hint="7"><hseparator></hseparator></window>'|gtkdialog -s -G +1+1 &
sleep .3

## Maximize test window
wmctrl -r @@ -b add,maximized_vert,maximized_horz

## Retrieve geometry
XWININFO=$(xwininfo -name @@)
set -- ${XWININFO#* X: }
WINMAX_X=$1
WINMAX_Y=$5
WINMAX_W=${15}
WINMAX_H=${17}

## Close test window
wmctrl -c @@

## Calculate widths/heigths occupied on each side by WM trays
TRAY_T=$WINMAX_Y
TRAY_R=$((SCREEN_W - WINMAX_W - WINMAX_X))
TRAY_B=$((SCREEN_H - WINMAX_H - WINMAX_Y))
TRAY_L=$WINMAX_X

gxmessage -c "Screen dimension (WxH):${SCREEN_W}x${SCREEN_H}

Space (in px, calculated from screen edges) reserved for trays
Top:  	$TRAY_T
Right:	$TRAY_R
Bottom:	$TRAY_B
Left: 	$TRAY_L"
geo_c
Posts: 2877
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2197 times
Been thanked: 872 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by geo_c »

All I can say is StickyJWM has greatly improved the quality of my life. It completely eliminates the need for the collection of wmctrl scripts I wrote to place applications on the desktop. By providing the ability to place two or four windows tiled on the monitor, and grow or shrink them with a quick keystroke, the desktop becomes quickly productive without having to worry about the specific xy coordinates of individual monitors, it makes life a lot easier.

geo_c
Old School Hipster, and Such

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by recobayu »

Thank you, @MochiMoppel.
I try to make gui for configuration like this.

stickyjwm-config.png
stickyjwm-config.png (53.28 KiB) Viewed 3168 times

and use your code:

Code: Select all

#!/bin/bash

## Read current screen dimension
ARRAY=($(xwininfo -root))
SCREEN_W=${ARRAY[27]}
SCREEN_H=${ARRAY[29]}

## Create 1px test window (no focus, no decoration, layer below, skip taskbar)
echo '<window title="@@" decorated="false"><hseparator></hseparator></window>'|gtkdialog -s -G +1+1 &
sleep .3

## Maximize test window
wmctrl -r @@ -b add,maximized_vert,maximized_horz

## Retrieve geometry
XWININFO=$(xwininfo -name @@)
set -- ${XWININFO#* X: }
WINMAX_X=$1
WINMAX_Y=$5
WINMAX_W=${15}
WINMAX_H=${17}

## Close test window
wmctrl -c @@

## Calculate widths/heigths occupied on each side by WM trays

margin_top=$WINMAX_Y
margin_left=$WINMAX_X
margin_bottom=$((SCREEN_H - WINMAX_H - WINMAX_Y))
margin_right=$((SCREEN_W - WINMAX_W - WINMAX_X))



#Xdialog --msgbox "Screen dimension (WxH):${SCREEN_W}x${SCREEN_H}

#Space (in px, calculated from screen edges) reserved for trays
#Top:  	$margin_top
#Left:	$margin_left
#Bottom:	$margin_bottom
#Right:	$margin_right" 0 0

export wd="$HOME/.stickyjwm"
if [ ! -d "$wd" ];then mkdir -p "$wd";fi


echo "margin_top: $margin_top
margin_left: $margin_left
margin_bottom: $margin_bottom
margin_right: $margin_right" > "$wd"/stickyjwm-conf


try_it(){
    echo '<button>
    <label>'$1'</label>
    <action>stickyjwm -'$1'</action>
   </button>'
}
export -f try_it

echo '
<window title="@@@">

 <hbox>
  <vbox>
   
   <hbox>
    <text><label>margin top:</label></text>
    <spinbutton>
     <default>'$margin_top'</default>
     <action>sed -i "s/margin_top:.*/margin_top: $spintop1/" "$wd"/stickyjwm-conf</action>
     <variable>spintop1</variable>
    </spinbutton>
   </hbox>
     
   <hbox>
    <text><label>margin left:</label></text>
    <spinbutton>
     <default>'$margin_left'</default>
     <action>sed -i "s/margin_left:.*/margin_left: $spinleft/" "$wd"/stickyjwm-conf</action>
     <variable>spinleft</variable>
    </spinbutton>
   </hbox>
     
   <hbox>
    <text><label>margin bottom:</label></text>
    <spinbutton>
     <default>'$margin_bottom'</default>
     <action>sed -i "s/margin_bottom:.*/margin_bottom: $spinbottom/" "$wd"/stickyjwm-conf</action>
     <variable>spinbottom</variable>
    </spinbutton>
   </hbox>
   
   <hbox>
    <text><label>margin right:</label></text>
    <spinbutton>
     <default>'$margin_right'</default>
     <action>sed -i "s/margin_right:.*/margin_right: $spinright/" "$wd"/stickyjwm-conf</action>
     <variable>spinright</variable>
    </spinbutton>
   </hbox>
   
  </vbox>
  
  <frame try it>
  <hbox space-fill="true" space-expand="true">
   
   '"`try_it left`"'
   
   <vbox space-fill="true" space-expand="true">
    '"`try_it up`"'
    '"`try_it down`"'
   </vbox>
  
   '"`try_it right`"'
  </hbox>
  </frame>
 </hbox>

</window>"'|gtkdialog -s

I change a little to make it works from your code, that is replace the type-hint="7" with decorated="false"
then, also change the stickyjwm script like this:

Code: Select all

#!/bin/bash

# 220321 partition screen into three height (h1 and h2 line as border)
#        and three width (w1 and w2 line as border)
# 220503 add margins

wd=`echo /tmp$HOME/.stickyjwm`
#echo "$wd"
#rm -r "$wd"
mkdir -p "$wd"

case "$1" in
	-h|--help) echo ' usage:
	-up 	: snap to top monitor
	-left 	: snap to left monitor
	-down 	: snap to bottom monitor
	-right 	: snap to right monitor'
esac

if [ -f $HOME/.stickyjwm/stickyjwm-conf ];then
    conf="$HOME/.stickyjwm/stickyjwm-conf"
    margin_top=`grep "margin_top:.*" "$conf"|cut -d\: -f2`
    margin_left=`grep "margin_left:.*" "$conf"|cut -d\: -f2`
    margin_bottom=`grep "margin_bottom:.*" "$conf"|cut -d\: -f2`
    margin_right=`grep "margin_right:.*" "$conf"|cut -d\: -f2`
    
    echo "$margin_top, $margin_left, $margin_bottom, $margin_right"
else
    mkdir $HOME/.stickyjwm/
    
    margin_top=0
    margin_left=0
    margin_bottom=0
    margin_right=0
    
    echo 'margin_top:0
margin_left:0
margin_bottom:0
margin_right:0' > "$HOME/.stickyjwm/stickyjwm-conf"
fi

# list all active monitors and sort it by x coordinate
xrandr --listactivemonitors|grep x|awk -F '[ +x/]' '{print $4,$5-'$margin_left'-'$margin_right',$7-'$margin_top'-'$margin_bottom',$9+'$margin_left',$10+'$margin_top'}'|sed 's/*//g'|sort -k4,4n > "$wd"/monitors-active

# debug
# name	w	h	x	y of monitor
#	0	1	2	3	4



## Get window position information
if [ ! -d "$wd"/info ];then mkdir -p "$wd"/info; fi
id_window=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW|cut -f2)
xwininfo -id $id_window>"$wd"/info/$id_window
w_window=`awk '/Width/{print $2}' "$wd"/info/$id_window`
h_window=`awk '/Height/{print $2}' "$wd"/info/$id_window`
x_window=`awk '/Absolute upper-left X/{print $4}' "$wd"/info/$id_window`
y_window=`awk '/Absolute upper-left Y/{print $4}' "$wd"/info/$id_window`
border=`awk '/Relative upper-left X/{print $4}' "$wd"/info/$id_window`
title=`awk '/Relative upper-left Y/{print $4}' "$wd"/info/$id_window`

# got the center coordinate of window
cx_window=$(( $x_window + $w_window / 2 ))
cy_window=$(( $y_window + $h_window / 2 ))


# check if there is a config file for this window.
if [ ! -f "$wd/$id_window" ];then		#if not found, then make it!


	while read line;do
		mntr=($line)
		
		#echo "${mntr[@]}"
		
		w_plus_x=$(( ${mntr[1]} + ${mntr[3]} ))
		#echo w_plus_x = "$w_plus_x"

		#echo "$x_window" "$w_plus_x"
		if [ "$x_window" -lt "$w_plus_x" ];then
			#echo "the window is on ${mntr[0]}"
			current=(${mntr[@]})
			echo "${current[@]}" > "$wd/$id_window"
			break
		#else
			#echo "the window is on the right of $mntr"
		fi
	done < "$wd"/monitors-active

else
	#echo "take from config file in $wd/$id_window"
	current=(`cat $wd/$id_window`)
fi
#echo "Selesai"
#echo current monitor: "${current[@]}"
echo

# set the margin into current monitor config
#current[1]=$(( ${current[1]} - $margin_left - $margin_right ))
#current[2]=$(( ${current[2]} - $margin_top - $margin_bottom ))
#current[3]=$(( ${current[3]} + $margin_left ))
#current[4]=$(( ${current[4]} + $margin_top ))

goto_left_monitor(){
	left=(`grep -B 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#left[@]} -eq 0 ];then left=(`tail -1 "$wd"/monitors-active`); fi
	echo ${left[@]} > "$wd/$id_window"
	current=(${left[@]})
}

goto_right_monitor(){
	right=(`grep -A 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#right[@]} -eq 0 ];then right=(`head -1 "$wd"/monitors-active`); fi
	echo ${right[@]} > "$wd/$id_window"
	current=(${right[@]})
}



# position window on monitor
# 1 | 2 | 3
#----------- h1
# 4 | 5 | 6
#----------- h2
# 7 | 8 | 9
#   w1  w2


w1=$(( ${current[3]} + ${current[1]} / 3 ))
w2=$(( ${current[3]} + ${current[1]} / 3 * 2))
h1=$(( ${current[4]} + ${current[2]} / 3 ))
h2=$(( ${current[4]} + ${current[2]} / 3 * 2))

echo cx:$cx_window, w: $w1, $w2, $(( ${current[1]} + ${current[3]} ))
echo cy:$cy_window, h: $h1, $h2, $(( ${current[2]} + ${current[4]} ))





# result
pos1(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos1 on ${current[0]}
}

pos2(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos2 on ${current[0]}
}

pos3(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos3 on ${current[0]}
}

pos4(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos4 on ${current[0]}
}

pos5(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=${current[2]}
	echo pos5 on ${current[0]}
}

pos6(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos6 on ${current[0]}
}

pos7(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos7 on ${current[0]}
}

pos8(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos8 on ${current[0]}
}

pos9(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos9 on ${current[0]}
}

center(){
	margin=150
	x=$(( ${current[3]} + $margin ))
	y=$(( ${current[4]} + $margin / 2 ))
	w=$(( ${current[1]} - 2 * $margin ))
	h=$(( ${current[2]} - $margin ))
	echo center on ${current[0]}
}




# check, where is this window position (1 - 9)
if [ $cy_window -lt $h1 ];then
	echo top of h1: 1, 2, 3
	if [ $cx_window -lt $w1 ];then
		echo 1
		case $1 in
			-up) goto_left_monitor; pos7;;
			-right) pos2;;
			-down) pos4;;
			-left) goto_left_monitor; pos3;;
			*) pos2;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 2
		case $1 in
			-up) pos5;;
			-right) pos3;;
			-down) center;;
			-left) pos1;;
			*) pos3;;
		esac
	else
		echo 3
		case $1 in
			-up) goto_left_monitor; pos9;;
			-right) goto_right_monitor; pos1;;
			-down) pos6;;
			-left) pos2;;
			*) goto_right_monitor; pos1;;
		esac
	fi
	
elif [ $cy_window -lt $h2 ];then
	echo between h1 and h2: 4, 5, 6
	if [ $cx_window -lt $w1 ];then
		echo 4
		case $1 in
			-up) pos1;;
			-right) center;;
			-down) pos7;;
			-left) goto_left_monitor; pos6;;
			*) center;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 5
		case $1 in
			-up) pos2;;
			-right) pos6;;
			-down) pos8;;
			-left) pos4;;
			*) pos6;;
		esac
	else
		echo 6
		case $1 in
			-up) pos3;;
			-right) goto_right_monitor; pos4;;
			-down) pos9;;
			-left) center;;
			*) goto_right_monitor; pos4;;
		esac
	fi
else
	echo bottom of h2: 7, 8, 9
	if [ $cx_window -lt $w1 ];then
		echo 7
		case $1 in
			-up) pos4;;
			-right) pos8;;
			-down) goto_right_monitor; pos1;;
			-left) goto_left_monitor; pos9;;
			*) pos8;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 8
		case $1 in
			-up) center;;
			-right) pos9;;
			-down) goto_right_monitor; pos2;;
			-left) pos7;;
			*) pos9;;
		esac
	else
		echo 9
		case $1 in
			-up) pos6;;
			-right) goto_right_monitor; pos7;;
			-down) goto_right_monitor; pos3;;
			-left) pos8;;
			*) goto_right_monitor; pos7;;
		esac
	fi
fi



# set up for border and decoration
w=$(( $w - 2*$border ))
h=$(( $h - $title - $border ))
echo x,y,w,h now
echo $x,$y,$w,$h


# run twice to make terminal better place
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
wmctrl -r :ACTIVE: -e 1,$x,$y,$w,$h

And this script for stickyxfce:

Code: Select all

#!/bin/bash

# 220321 partition screen into three height (h1 and h2 line as border)
#        and three width (w1 and w2 line as border)
# 220503 add margins

wd=`echo /tmp$HOME/.stickyjwm`
#echo "$wd"
#rm -r "$wd"
mkdir -p "$wd"

case "$1" in
	-h|--help) echo ' usage:
	-up 	: snap to top monitor
	-left 	: snap to left monitor
	-down 	: snap to bottom monitor
	-right 	: snap to right monitor'
esac

if [ -f $HOME/.stickyjwm/stickyjwm-conf ];then
    conf="$HOME/.stickyjwm/stickyjwm-conf"
    margin_top=`grep "margin_top:.*" "$conf"|cut -d\: -f2`
    margin_left=`grep "margin_left:.*" "$conf"|cut -d\: -f2`
    margin_bottom=`grep "margin_bottom:.*" "$conf"|cut -d\: -f2`
    margin_right=`grep "margin_right:.*" "$conf"|cut -d\: -f2`
    
    echo "$margin_top, $margin_left, $margin_bottom, $margin_right"
else
    mkdir $HOME/.stickyjwm/
    
    margin_top=0
    margin_left=0
    margin_bottom=0
    margin_right=0
    
    echo 'margin_top:0
margin_left:0
margin_bottom:0
margin_right:0' > "$HOME/.stickyjwm/stickyjwm-conf"
fi

# list all active monitors and sort it by x coordinate
xrandr --listactivemonitors|grep x|awk -F '[ +x/]' '{print $4,$5-'$margin_left'-'$margin_right',$7-'$margin_top'-'$margin_bottom',$9+'$margin_left',$10+'$margin_top'}'|sed 's/*//g'|sort -k4,4n > "$wd"/monitors-active

# debug
# name	w	h	x	y of monitor
#	0	1	2	3	4



## Get window position information
if [ ! -d "$wd"/info ];then mkdir -p "$wd"/info; fi
id_window=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW|cut -f2)
xwininfo -id $id_window>"$wd"/info/$id_window
w_window=`awk '/Width/{print $2}' "$wd"/info/$id_window`
h_window=`awk '/Height/{print $2}' "$wd"/info/$id_window`
x_window=`awk '/Absolute upper-left X/{print $4}' "$wd"/info/$id_window`
y_window=`awk '/Absolute upper-left Y/{print $4}' "$wd"/info/$id_window`
border=`awk '/Relative upper-left X/{print $4}' "$wd"/info/$id_window`
title=`awk '/Relative upper-left Y/{print $4}' "$wd"/info/$id_window`

# got the center coordinate of window
cx_window=$(( $x_window + $w_window / 2 ))
cy_window=$(( $y_window + $h_window / 2 ))


# check if there is a config file for this window.
if [ ! -f "$wd/$id_window" ];then		#if not found, then make it!


	while read line;do
		mntr=($line)
		
		#echo "${mntr[@]}"
		
		w_plus_x=$(( ${mntr[1]} + ${mntr[3]} ))
		#echo w_plus_x = "$w_plus_x"

		#echo "$x_window" "$w_plus_x"
		if [ "$x_window" -lt "$w_plus_x" ];then
			#echo "the window is on ${mntr[0]}"
			current=(${mntr[@]})
			echo "${current[@]}" > "$wd/$id_window"
			break
		#else
			#echo "the window is on the right of $mntr"
		fi
	done < "$wd"/monitors-active

else
	#echo "take from config file in $wd/$id_window"
	current=(`cat $wd/$id_window`)
fi
#echo "Selesai"
#echo current monitor: "${current[@]}"
echo

# set the margin into current monitor config
#current[1]=$(( ${current[1]} - $margin_left - $margin_right ))
#current[2]=$(( ${current[2]} - $margin_top - $margin_bottom ))
#current[3]=$(( ${current[3]} + $margin_left ))
#current[4]=$(( ${current[4]} + $margin_top ))

goto_left_monitor(){
	left=(`grep -B 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#left[@]} -eq 0 ];then left=(`tail -1 "$wd"/monitors-active`); fi
	echo ${left[@]} > "$wd/$id_window"
	current=(${left[@]})
}

goto_right_monitor(){
	right=(`grep -A 1 "${current[0]}" "$wd"/monitors-active|grep -v "${current[0]}"`)
	if [ ${#right[@]} -eq 0 ];then right=(`head -1 "$wd"/monitors-active`); fi
	echo ${right[@]} > "$wd/$id_window"
	current=(${right[@]})
}



# position window on monitor
# 1 | 2 | 3
#----------- h1
# 4 | 5 | 6
#----------- h2
# 7 | 8 | 9
#   w1  w2


w1=$(( ${current[3]} + ${current[1]} / 3 ))
w2=$(( ${current[3]} + ${current[1]} / 3 * 2))
h1=$(( ${current[4]} + ${current[2]} / 3 ))
h2=$(( ${current[4]} + ${current[2]} / 3 * 2))

echo cx:$cx_window, w: $w1, $w2, $(( ${current[1]} + ${current[3]} ))
echo cy:$cy_window, h: $h1, $h2, $(( ${current[2]} + ${current[4]} ))





# result
pos1(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos1 on ${current[0]}
}

pos2(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos2 on ${current[0]}
}

pos3(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos3 on ${current[0]}
}

pos4(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos4 on ${current[0]}
}

pos5(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=${current[2]}
	echo pos5 on ${current[0]}
}

pos6(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos6 on ${current[0]}
}

pos7(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos7 on ${current[0]}
}

pos8(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos8 on ${current[0]}
}

pos9(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos9 on ${current[0]}
}

center(){
	margin=150
	x=$(( ${current[3]} + $margin ))
	y=$(( ${current[4]} + $margin / 2 ))
	w=$(( ${current[1]} - 2 * $margin ))
	h=$(( ${current[2]} - $margin ))
	echo center on ${current[0]}
}




# check, where is this window position (1 - 9)
if [ $cy_window -lt $h1 ];then
	echo top of h1: 1, 2, 3
	if [ $cx_window -lt $w1 ];then
		echo 1
		case $1 in
			-up) pos5;;
			-right) pos2;;
			-down) pos4;;
			-left) goto_left_monitor; pos3;;
			*) pos2;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 2
		case $1 in
			-up) pos5;;
			-right) pos3;;
			-down) center;;
			-left) pos1;;
			*) pos3;;
		esac
	else
		echo 3
		case $1 in
			-up) pos5;;
			-right) goto_right_monitor; pos1;;
			-down) pos6;;
			-left) pos2;;
			*) goto_right_monitor; pos1;;
		esac
	fi
	
elif [ $cy_window -lt $h2 ];then
	echo between h1 and h2: 4, 5, 6
	if [ $cx_window -lt $w1 ];then
		echo 4
		case $1 in
			-up) pos1;;
			-right) center;;
			-down) pos7;;
			-left) goto_left_monitor; pos6;;
			*) center;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 5
		case $1 in
			-up) pos2;;
			-right) pos6;;
			-down) pos8;;
			-left) pos4;;
			*) pos6;;
		esac
	else
		echo 6
		case $1 in
			-up) pos3;;
			-right) goto_right_monitor; pos4;;
			-down) pos9;;
			-left) center;;
			*) goto_right_monitor; pos4;;
		esac
	fi
else
	echo bottom of h2: 7, 8, 9
	if [ $cx_window -lt $w1 ];then
		echo 7
		case $1 in
			-up) pos4;;
			-right) pos8;;
			-down) goto_right_monitor; pos1;;
			-left) goto_left_monitor; pos9;;
			*) pos8;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 8
		case $1 in
			-up) center;;
			-right) pos9;;
			-down) goto_right_monitor; pos2;;
			-left) pos7;;
			*) pos9;;
		esac
	else
		echo 9
		case $1 in
			-up) pos6;;
			-right) goto_right_monitor; pos7;;
			-down) goto_right_monitor; pos3;;
			-left) pos8;;
			*) goto_right_monitor; pos7;;
		esac
	fi
fi



# set up for border and decoration
w=$(( $w - 2*$border ))
h=$(( $h - $title - $border ))
echo x,y,w,h now
echo $x,$y,$w,$h


# run twice to make terminal better place
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
wmctrl -r :ACTIVE: -e 1,$x,$y,$w,$h


Last edited by recobayu on Sat Aug 20, 2022 3:58 pm, edited 3 times in total.
User avatar
MochiMoppel
Posts: 1229
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 21 times
Been thanked: 436 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by MochiMoppel »

recobayu wrote: Wed May 18, 2022 8:55 am

I change a little to make it works from your code, that is replace the type-hint="7" with decorated="false"

Why? Xfwm doesn't support it? My main reason to use type-hint="7" is its ability to open the test window under any other window, thus making it as invisible as possible and further reduce the flicker.

recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by recobayu »

Hi @MochiMoppel, when I use type-hint="7", it give me wrong margin like this:
margin top: 60
margin left: 1
margin bottom: 100
margin right: 100

and I think the window doesn't maximize.
I try it on voidpup64.

Update: This code is implement mochi's idea on multiple monitors to calculate the margins.

Code: Select all

#!/bin/bash

#dapatkan idwindownya
id=`xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW|cut -f2`
#echo $id
info=`xwininfo -id $id`
#echo "$info"

#dapatkan whxy window sebelum difullscreen
w_window=`echo "$info"|awk '/Width/{print $2}'`
h_window=`echo "$info"|awk '/Height/{print $2}'`
x_window=`echo "$info"|awk '/Absolute upper-left X/{print $4}'`
y_window=`echo "$info"|awk '/Absolute upper-left Y/{print $4}'`

#hilangkan dekorasi windownya
xprop -id "$id" -format _MOTIF_WM_HINTS 32i -set _MOTIF_WM_HINTS 2

#buat window menjadi maximized
wmctrl -ir "$id" -b add,maximized_vert,maximized_horz
sleep .1
info=`xwininfo -id $id`

#dapatkan whxy window setelah difullscreen
w_full=`echo "$info"|awk '/Width/{print $2}'`
h_full=`echo "$info"|awk '/Height/{print $2}'`
x_full=`echo "$info"|awk '/Absolute upper-left X/{print $4}'`
y_full=`echo "$info"|awk '/Absolute upper-left Y/{print $4}'`

monitors=`xrandr --listactivemonitors|grep x|awk -F '[ +x/]' '{print $12, $5, $7, $9, $10}'|sort -k4,4n`
echo "$monitors"
echo '---------------'
while read line;do
	monitor=($line)
	w_monitor=${monitor[1]}
	h_monitor=${monitor[2]}
	x_monitor=${monitor[3]}
	y_monitor=${monitor[4]}
	x_diff=$[x_full - w_monitor - x_monitor ]
	y_diff=$[y_full - h_monitor - y_monitor ]
	
	if [ "$x_diff" -le 0 -a "$y_diff" -le 0 ];then
		top_margin=$[y_full - y_monitor]
		left_margin=$[x_full - x_monitor]
		bottom_margin=$[h_monitor - h_full - top_margin]
		right_margin=$[w_monitor - w_full - left_margin]
			
		if [ $top_margin -lt 0 -o $left_margin -lt 0 -o $bottom_margin -lt 0 -o $right_margin -lt 0 ];then
			continue
		else
			break
		fi
	fi
done <<< "$monitors"

echo top:$top_margin
echo left:$left_margin
echo bottom:$bottom_margin
echo right:$right_margin

#munculkan lagi dekorasi windownya
xprop -id "$id" -format _MOTIF_WM_HINTS 32i -set _MOTIF_WM_HINTS 0
wmctrl -ir "$id" -b remove,maximized_vert,maximized_horz
recobayu
Posts: 64
Joined: Tue Jul 14, 2020 9:34 am
Has thanked: 11 times
Been thanked: 8 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by recobayu »

I make this implementation of @MochiMoppel's idea. It flicker when change monitor to detect automatically whxy of fullscreen window.
stickyxfce

Code: Select all

#!/bin/bash

# 220321 partition screen into three height (h1 and h2 line as border)
#        and three width (w1 and w2 line as border)
# 220503 add margins
# 220816 set margins automatically when go to another monitor


wd=`echo /tmp$HOME/.stickyjwm`
#echo "$wd"
#rm -r "$wd"
mkdir -p "$wd"

case "$1" in
	-h|--help) echo ' usage:
	-up 	: snap to top monitor
	-left 	: snap to left monitor
	-down 	: snap to bottom monitor
	-right 	: snap to right monitor'
esac

#get the idwindow and information about it
id=`xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW|cut -f2`
info=`xwininfo -id $id`

#get the whxy window before fullscreen-ed
w_window=`echo "$info"|awk '/Width/{print $2}'`
h_window=`echo "$info"|awk '/Height/{print $2}'`
x_window=`echo "$info"|awk '/Absolute upper-left X/{print $4}'`
y_window=`echo "$info"|awk '/Absolute upper-left Y/{print $4}'`
border=`echo "$info"|awk '/Relative upper-left X/{print $4}'`
title=`echo "$info"|awk '/Relative upper-left Y/{print $4}'`

#find the maximized window properties of current monitor
maximized(){
#set the window decoration gone (it doesn't effect anything in xfce, so I comment it)
#xprop -id "$id" -format _MOTIF_WM_HINTS 32i -set _MOTIF_WM_HINTS 2

#maximized the window (thank you, Mochimoppel)
wmctrl -ir "$id" -b add,maximized_vert,maximized_horz
sleep .1
info=`xwininfo -id $id`

#get the whxy window after fullscreen-ed
w_full=`echo "$info"|awk '/Width/{print $2}'`
h_full=`echo "$info"|awk '/Height/{print $2}'`
x_full=`echo "$info"|awk '/Absolute upper-left X/{print $4}'`
y_full=`echo "$info"|awk '/Absolute upper-left Y/{print $4}'`


#set the window decoration appear (it doesn't effect anything in xfce, so I comment it)
#xprop -id "$id" -format _MOTIF_WM_HINTS 32i -set _MOTIF_WM_HINTS 0
wmctrl -ir "$id" -b remove,maximized_vert,maximized_horz

current[1]=$w_full
current[2]=$[h_full + title]
current[3]=$x_full
current[4]=$[y_full - title]
echo ${current[@]} > "$wd/$id"
}

monitors=`xrandr --listactivemonitors|grep x|awk -F '[ +x/]' '{print $12, $5, $7, $9, $10}'|sort -k4,4n`
echo "$monitors"

# debug
#	name	w	h	x	y of monitor
#	0		1	2	3	4



## Get window position information

# got the center coordinate of window
cx_window=$(( $x_window + $w_window / 2 ))
cy_window=$(( $y_window + $h_window / 2 ))


# check if there is a config file for this window.
if [ ! -f "$wd/$id" ];then		#if not found, then make it!


	while read line;do
		mntr=($line)
		
		#echo "${mntr[@]}"
		
		w_plus_x=$(( ${mntr[1]} + ${mntr[3]} ))
		#echo w_plus_x = "$w_plus_x"

		#echo "$x_window" "$w_plus_x"
		if [ "$x_window" -lt "$w_plus_x" ];then
			#echo "the window is on ${mntr[0]}"
			current=(${mntr[@]})
			echo "${current[@]}" > "$wd/$id"
			break
		#else
			#echo "the window is on the right of $mntr"
		fi
	done <<< "$monitors"

else
	#echo "take from config file in $wd/$id_window"
	current=(`cat $wd/$id`)
fi
#echo "Finished"
#echo current monitor: "${current[@]}"
echo

goto_left_monitor(){
	left=(`echo "$monitors"|grep -B 1 "${current[0]}"|grep -v "${current[0]}"`)
	if [ ${#left[@]} -eq 0 ];then left=(`echo "$monitors"|tail -1`); fi
	current=(${left[@]})
	wmctrl -r :ACTIVE: -e 1,${current[3]},-1,-1,-1
	maximized
}

goto_right_monitor(){
	right=(`echo "$monitors"|grep -A 1 "${current[0]}"|grep -v "${current[0]}"`)
	if [ ${#right[@]} -eq 0 ];then right=(`echo "$monitors"|head -1`); fi
	current=(${right[@]})
	wmctrl -r :ACTIVE: -e 1,${current[3]},-1,-1,-1
	maximized
}



# position window on monitor
# 1 | 2 | 3
#----------- h1
# 4 | 5 | 6
#----------- h2
# 7 | 8 | 9
#   w1  w2


w1=$(( ${current[3]} + ${current[1]} / 3 ))
w2=$(( ${current[3]} + ${current[1]} / 3 * 2))
h1=$(( ${current[4]} + ${current[2]} / 3 ))
h2=$(( ${current[4]} + ${current[2]} / 3 * 2))

echo cx:$cx_window, w: $w1, $w2, $(( ${current[1]} + ${current[3]} ))
echo cy:$cy_window, h: $h1, $h2, $(( ${current[2]} + ${current[4]} ))





# result
pos1(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos1 on ${current[0]}
}

pos2(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos2 on ${current[0]}
}

pos3(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos3 on ${current[0]}
}

pos4(){
	x=${current[3]}
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos4 on ${current[0]}
}

pos5(){
	x=${current[3]}
	y=${current[4]}
	w=${current[1]}
	h=${current[2]}
	echo pos5 on ${current[0]}
}

pos6(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=${current[4]}
	w=$(( ${current[1]} / 2 ))
	h=${current[2]}
	echo pos6 on ${current[0]}
}

pos7(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos7 on ${current[0]}
}

pos8(){
	x=${current[3]}
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=${current[1]}
	h=$(( ${current[2]} / 2 ))
	echo pos8 on ${current[0]}
}

pos9(){
	x=$(( ${current[3]} + ${current[1]} / 2 ))
	y=$(( ${current[4]} + ${current[2]} / 2 ))
	w=$(( ${current[1]} / 2 ))
	h=$(( ${current[2]} / 2 ))
	echo pos9 on ${current[0]}
}

center(){
	margin=150
	x=$(( ${current[3]} + $margin ))
	y=$(( ${current[4]} + $margin / 2 ))
	w=$(( ${current[1]} - 2 * $margin ))
	h=$(( ${current[2]} - $margin ))
	echo center on ${current[0]}
}




# check, where is this window position (1 - 9)
if [ $cy_window -lt $h1 ];then
	echo top of h1: 1, 2, 3
	if [ $cx_window -lt $w1 ];then
		echo 1
		case $1 in
			-up) pos5;;
			-right) pos2;;
			-down) pos4;;
			-left) goto_left_monitor; pos3;;
			*) pos2;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 2
		case $1 in
			-up) pos5;;
			-right) pos3;;
			-down) center;;
			-left) pos1;;
			*) pos3;;
		esac
	else
		echo 3
		case $1 in
			-up) pos5;;
			-right) goto_right_monitor; pos1;;
			-down) pos6;;
			-left) pos2;;
			*) goto_right_monitor; pos1;;
		esac
	fi
	
elif [ $cy_window -lt $h2 ];then
	echo between h1 and h2: 4, 5, 6
	if [ $cx_window -lt $w1 ];then
		echo 4
		case $1 in
			-up) pos1;;
			-right) center;;
			-down) pos7;;
			-left) goto_left_monitor; pos6;;
			*) center;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 5
		case $1 in
			-up) pos2;;
			-right) pos6;;
			-down) pos8;;
			-left) pos4;;
			*) pos6;;
		esac
	else
		echo 6
		case $1 in
			-up) pos3;;
			-right) goto_right_monitor; pos4;;
			-down) pos9;;
			-left) center;;
			*) goto_right_monitor; pos4;;
		esac
	fi
else
	echo bottom of h2: 7, 8, 9
	if [ $cx_window -lt $w1 ];then
		echo 7
		case $1 in
			-up) pos4;;
			-right) pos8;;
			-down) goto_right_monitor; pos1;;
			-left) goto_left_monitor; pos9;;
			*) pos8;;
		esac
	elif [ $cx_window -lt $w2 ];then
		echo 8
		case $1 in
			-up) center;;
			-right) pos9;;
			-down) goto_right_monitor; pos2;;
			-left) pos7;;
			*) pos9;;
		esac
	else
		echo 9
		case $1 in
			-up) pos6;;
			-right) goto_right_monitor; pos7;;
			-down) goto_right_monitor; pos3;;
			-left) pos8;;
			*) goto_right_monitor; pos7;;
		esac
	fi
fi



# set up for border and decoration
w=$(( $w - 2*$border ))
h=$(( $h - $title - $border ))
echo x,y,w,h now
echo $x,$y,$w,$h


# run twice to make terminal better place
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz
#wmctrl -r :ACTIVE: -e 0,$x,$y,$w,$h
wmctrl -r :ACTIVE: -e 1,$x,$y,$w,$h


Edit: It still failed on some monitor placement :(

User avatar
MochiMoppel
Posts: 1229
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 21 times
Been thanked: 436 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by MochiMoppel »

recobayu wrote: Tue Aug 16, 2022 3:49 pm

I make this implementation of @MochiMoppel's idea. It flicker when change monitor to detect automatically whxy of fullscreen window.

Looks like a bad idea . :roll:

I tested MochiMoppel's idea without type-hint but with a decorated test window (forgot to set it to undecorated) ... and it failed . I think it should better calculate with relative, not absolute dimensions. The flicker is truly annoying.

I have a better idea - again :lol:
This works for me with JWM. Apart from a single call to xprop it uses only bash and bash built-ins. No wmctrl, no awk, no cut, no maximizing, no flicker. May also work in XFCE, but not guaranteed as the calculation of the _NET_WORKAREA property is at the discretion of the window manager.

Code: Select all

#!/bin/sh
read DUMMY SCREEN_W SCREEN_H DUMMY MARGIN_L MARGIN_T MAXWIN_W MAXWIN_H <<< $(xprop -root 32c ' $0 $1 ' _NET_DESKTOP_GEOMETRY 32c ' $0 $1 $2 $3 ' _NET_WORKAREA)
MARGIN_R=$((SCREEN_W-MARGIN_L-MAXWIN_W))
MARGIN_B=$((SCREEN_H-MARGIN_T-MAXWIN_H))

gxmessage -c "Screen dimension (WxH):${SCREEN_W}x${SCREEN_H}

Space (in px, calculated from screen edges) reserved for trays
Top:  	$MARGIN_T
Right:	$MARGIN_R
Bottom:	$MARGIN_B
Left: 	$MARGIN_L

Maximum possible size (WxH) of a window not allowed to cover trays:
${MAXWIN_W}x${MAXWIN_H}"
calculating_usable_area.png
calculating_usable_area.png (15.45 KiB) Viewed 2891 times

Above test was made with 3 trays (top,left,bottom), all set to autohide="false". Setting autohide to true would correctly remove the margin.

Personally I prefer the set command (also a bash built-in) for its readability and speed:

Code: Select all

set -- $(xprop -root 32c ' $0 $1 ' _NET_DESKTOP_GEOMETRY 32c ' $0 $1 $2 $3 ' _NET_WORKAREA)
SCREEN_W=$2
SCREEN_H=$3
MARGIN_L=$5
MARGIN_T=$6
MARGIN_R=$(($2-$5-$7))
MARGIN_B=$(($3-$6-$8))
set --

echo "Screen width,height: $SCREEN_W $SCREEN_H"
echo "Margins (t,r,b,l): $MARGIN_T $MARGIN_R $MARGIN_B $MARGIN_L" 
geo_c
Posts: 2877
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2197 times
Been thanked: 872 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by geo_c »

Which one of these scripts is the official "working" version for XFCE?

I want to add it to KLV because I'm completely dependent on the JWM version in Fossapup. It's indespensable at this point.

geo_c
Old School Hipster, and Such

User avatar
MochiMoppel
Posts: 1229
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 21 times
Been thanked: 436 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by MochiMoppel »

geo_c wrote: Thu Oct 06, 2022 11:09 pm

Which one of these scripts is the official "working" version for XFCE?

Do my scripts work with XFCE?

geo_c
Posts: 2877
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2197 times
Been thanked: 872 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by geo_c »

MochiMoppel wrote: Fri Oct 07, 2022 3:29 am
geo_c wrote: Thu Oct 06, 2022 11:09 pm

Which one of these scripts is the official "working" version for XFCE?

Do my scripts work with XFCE?

I haven't tried it, because I downloaded a pet and I'm not quite sure where it even copied itself, but I could copy the code and try and give it a whirl.

I linked to this post: viewtopic.php?p=56582#p56582 from some other post on the forum and it looked like there might be a separate script for XCFE.

geo_c
Old School Hipster, and Such

geo_c
Posts: 2877
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2197 times
Been thanked: 872 times

Re: Stickyjwm and Stickyxfce-- Control Windows

Post by geo_c »

MochiMoppel wrote: Fri Oct 07, 2022 3:29 am
geo_c wrote: Thu Oct 06, 2022 11:09 pm

Which one of these scripts is the official "working" version for XFCE?

Do my scripts work with XFCE?

@rockedge added it to the latest KLV, so I don't need it at this point, since KLV is the only XFCE desktop I currently run. Maybe those two scripts should be made into packages for future pups, dogs, and weedogs. I can't comfortably navigate my computer without it anymore.

geo_c
Old School Hipster, and Such

Post Reply

Return to “Desktop”