Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-07-09 00:56:12

Mellowbob
Member
Registered: 2011-10-16
Posts: 199

Force window to start tiled

I've got a little shell script that opens 2 windows, a pdf viewer and a copy of emacs. I want the viewer to open tiled (snapped) to the left side of the screen and the editor to the right. I certainly can do this manually, but there must be a way to automate it? Oh, and I don't want the 2 programs to always behave this way, just when I call it from the script.

Thanks.

Offline

#2 2020-07-09 01:36:12

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,865

Re: Force window to start tiled

Assuming that you have Snap Left and Snap Right set to Ctrl+Left and Ctrl+Right respectively in Settings Manager > Window Manager > Keyboard, and you have xdotool installed, you can use a script like this:

#!/bin/bash

emacs &
sleep 1
xdotool key Ctrl+Right
atril &
sleep 1
xdotool key Ctrl+Left

Note, I'm using atril as the pdf viewer. Change the applications and sleep values to suit.

Offline

#3 2020-07-09 02:31:38

Mellowbob
Member
Registered: 2011-10-16
Posts: 199

Re: Force window to start tiled

I'll have to review xdotool ... but right now it's not working for me. Making sure I did not copy incorrectly, I have:

#!/bin/bash

emacs &
sleep 1
xdotool key Ctrl+Right
atril &
sleep 1
xdotool key Ctrl+Left

But I just get a regular emacs and atril. Running the script in the background makes no difference.

My xdotool is: xdotool version 3.20160805.1

Doing a very quick scan of the manual, it seems I need a window id? But I'm really not sure.

Offline

#4 2020-07-09 11:22:22

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,865

Re: Force window to start tiled

Does Ctrl+Left tile the window to the left for you for any application? Maybe the keyboard shortcut is different. Check in Settings Manager > Window Manager > Keyboard to see what your "Tile window to the left" keyboard shortcut is.

Offline

#5 2020-07-09 16:14:49

Mellowbob
Member
Registered: 2011-10-16
Posts: 199

Re: Force window to start tiled

Not ctrl-left/right on this system. There is no reference to tiling in keyboard at all. However, the function does work via Super-Left/Right, etc. I'll try the script later and let you know.

Offline

#6 2020-07-09 23:56:37

Mellowbob
Member
Registered: 2011-10-16
Posts: 199

Re: Force window to start tiled

Works perfectly with Super-Left, etc. Thanks for the help.

Offline

Board footer

Powered by FluxBB