[Solved] How can we lock window size and position?

Everything about X, Gnome, KDE, ... and everything running on it

[Solved] How can we lock window size and position?

Postby bester69 » 2019-11-05 16:09

Hi,
I was trying to fix a simple window application in the screen, so I cant move it accidentally with the mouse, neither resize it..

Using plasma, I tried to play with kwin rules.. but there is no choice to force "unable to move/drag window", the more close option i found, was to transform regular window in "desktop window" or force it to "remove title bar", the first one, doesnt allow me to keep in foreground the window, and the second one, thought is ok to prevent resizing window, doesnt prevent me to move/drag the window around the display. So I cant find a way to disable drag window (Win + Alt + Mouse).. and i use a lot the regular shortcut to drag windows.

right now, Ive two kwin rules applied by title name to remove border window so I cant resize it:
modal.sh (remove border window)
Code: Select all
#!/bin/sh
wmctrl -r :ACTIVE: -T "modal"


Image

normal.sh (bring back border/title bar window)
Code: Select all
#!/bin/sh
wmctrl -r :ACTIVE: -T "normal"
Last edited by bester69 on 2019-11-05 16:59, edited 2 times in total.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1498
Joined: 2015-04-02 13:15

Re: How can I lock window size and position?

Postby bester69 » 2019-11-05 16:53

Curiously, forcing position with title bar removed, made it,

this is not working properly as that option should fix window start position to thoses coordenates..insteed it doesnt matter what coordenate you set, it just lock dragging windows.. which is what is was lookin for. :o

Image
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1498
Joined: 2015-04-02 13:15

Re: [Solved] How can I lock window size and position?

Postby bester69 » 2019-11-05 16:56

Can we use a windows tiling manger for this purpose within KDE or Gnome??

Can we use i3wm for this purpose, as an app? :roll:
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1498
Joined: 2015-04-02 13:15

Re: [Solved] How can I lock window size and position?

Postby bester69 » 2019-11-06 05:23

bester69 wrote:Can we use a windows tiling manger for this purpose within KDE or Gnome??

Can we use i3wm for this purpose, as an app? :roll:

Ok, I see we can switch between i3 and kwin with relative easily. Very Interesting :) :o

i3wm.sh (switch to plasma + i3)
Code: Select all
#!/bin/sh
killall kwin_x11 &
sleep 2 && killall kwin_x11 -9
killall kwin
i3 &


plasma.sh (switch to plasma + kwin)
Code: Select all
#!/bin/sh
#
killall plasmashell
killall i3
sleep 2
kstart plasmashell &
kstart kwin_x11 &


Image
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1498
Joined: 2015-04-02 13:15

Re: [Solved] How can we lock window size and position?

Postby bester69 » 2019-11-06 05:40

Blocking size and position of window in display by using Plasma krules.: (VERSION 2.)
--
Last edited by bester69 on 2019-11-06 16:05, edited 1 time in total.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1498
Joined: 2015-04-02 13:15

Re: [Solved] How can we lock window size and position?

Postby bester69 » 2019-11-06 16:05

Blocking size and position of window in display by using Plasma krules.: (VERSION 2.1)

.config/kwinrulesrc
Code: Select all
[1]
Description=modal
noborder=true
noborderrule=2
position=17,18
positionrule=2
types=1
wmclass=xxxxx
wmclasscomplete=false
wmclassmatch=2

[2]
Description=normal
noborder=false
noborderrule=2
types=0
wmclass=
wmclasscomplete=false
wmclassmatch=0

[General]
count=2



snapN.sh
- Remove title bar of classname application
- Block position to coordeantes of application

Code: Select all
#!/bin/sh
# Remove Bar title y Forzar posicion
# qdbus org.kde.KWin /KWin reconfigure

frule=/home/user/.config/kwinrulesrc
fruletmp=/tmp/kwinrulesrc
Af=$(xdotool getactivewindow getwindowname)
A=$(echo $Af | awk '{ print $NF }')
#cp $frule ~/kwinrulesrc-`date +%Y-%m-%d_%H:%M:%S`

# Get the coordinates of the active window's
#    top-left corner, and the window's size.
#    This excludes the window decoration.
  unset x y w h
  eval $(xwininfo -id $(xdotool getactivewindow) |
    sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
  echo -n "$x $y $w $h"

Modal='[4]
Description=modal
noborder=true
noborderrule=2
position=60,60
positionrule=1
types=0
wmclass=konsole
wmclasscomplete=false
wmclassmatch=2
'

#sleep 2
cat $frule > $fruletmp

refn=$(grep -n  "Description=modal" $fruletmp | cut -d':' -f 1)
N_noborder=$(($refn + 1))
N_noborderrule=$(($refn + 2))
N_position=$(($refn + 3))
N_positionrule=$(($refn + 4))
N_types=$(($refn + 5))
N_wmclass=$(($refn + 6))
N_wmclassmatch=$(($refn + 8))

sed  -i $N_noborder"c\noborder=true"  $fruletmp
sed  -i $N_noborderrule"c\noborderrule=2"  $fruletmp
sed  -i $N_position"c\position=$x,$y"  $fruletmp
sed  -i $N_positionrule"c\positionrule=2"  $fruletmp
sed  -i $N_types"c\types=1"  $fruletmp
sed  -i $N_wmclass"c\wmclass=$A"  $fruletmp
sed  -i $N_wmclassmatch"c\wmclassmatch=2"  $fruletmp
cat  $fruletmp  > $frule
qdbus org.kde.KWin /KWin reconfigure


snapM.sh
- Restore title bar and state for all applications
Code: Select all
#!/bin/sh
# Remove Bar title y Forzar posicion
# qdbus org.kde.KWin /KWin reconfigure
#wmctrl -r :ACTIVE: -T "normal"
frule=/home/user/.config/kwinrulesrc
fruletmp=/tmp/kwinrulesrc

Normal='[5]
Description=normal
noborder=false
noborderrule=2
types=1
wmclass=
wmclasscomplete=false
wmclassmatch=0
'

Modal='[4]
Description=modal
noborder=true
noborderrule=2
position=60,60
positionrule=1
types=1
wmclass=XXXXX
wmclasscomplete=false
wmclassmatch=2
'
cat $frule > $fruletmp

# Desactiva regla Modal
refn=$(grep -n  "Description=modal" $fruletmp | cut -d':' -f 1)
N_wmclass=$(($refn + 6))
sed  -i $N_wmclass"c\wmclass=XXXXX"  $fruletmp

# Aplica regla Normal A todas, para q recuperen Barra título (types=1)
refn=$(grep -n  "Description=normal" $fruletmp | cut -d':' -f 1)
N_types=$(($refn + 3))
sed  -i $N_types"c\types=1"  $fruletmp

cat  $fruletmp  > $frule
qdbus org.kde.KWin /KWin reconfigure

sleep 1 && sed  -i $N_types"c\types=0"  $fruletmp

cat  $fruletmp  > $frule
qdbus org.kde.KWin /KWin reconfigure

bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1498
Joined: 2015-04-02 13:15


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 7 guests

fashionable