Window Shuffler: It's possible to use a CLI to run apps at a specific tilling position?

Hi, I use Ubuntu Budgie 20.04 and I wanted to, for example, run a bash script to start 2 video players side by side.

Is there a command line tool in Window Shuffler to do that?

window-shuffler-awesome-tool "nemo $HOME" top-right
nemo $HOME && window-shuffler-awesome-tool "$!" left

I hope I’m not dreaming too much :grin:

Its an interesting idea - I’ve raised it on our github issue tracker to consider.


Note that you can already do that, if you are familiar with scripting, using new window action (gsettings option) of shuffler. Make new window action run a script to open one or more windows, have it wait for the window (-class) to appear, position them conditionally using tile-active (which also takes the window id as argument).
Ican imagine it sounds a bit complicated though. It is part of new shuffler features under the name window rules. -to be continued-.

1 Like

Thank you very much, I’ll try this for now

Couldn’t use gsetting as you suggested because of lack of IQ, but as I couldn’t waste too much time on it I created a solution using xdotool to get window ID and then /usr/lib/budgie-window-shuffler/tile_active to position it.

#!/bin/bash -e


position_list="maximize, right, left, top-right, top-left, bottom-right, bottom-left"

set_position() {
  if [ "${position}" == 'top-right' ]; then
    /usr/lib/budgie-window-shuffler/tile_active 1 0 2 2 "id=$1"
  elif [ "${position}" == 'top-left' ]; then
    /usr/lib/budgie-window-shuffler/tile_active 0 0 2 2 "id=$1"
  elif [ "${position}" == 'bottom-right' ]; then
    /usr/lib/budgie-window-shuffler/tile_active 1 1 2 2 "id=$1"
  elif [ "${position}" == 'bottom-left' ]; then
    /usr/lib/budgie-window-shuffler/tile_active 0 1 2 2 "id=$1"
  elif [ "${position}" == 'right' ]; then
    /usr/lib/budgie-window-shuffler/tile_active 1 0 2 1 "id=$1"
  elif [ "${position}" == 'left' ]; then
    /usr/lib/budgie-window-shuffler/tile_active 0 0 2 1 "id=$1"
  elif [ "${position}" == 'maximize' ]; then
    /usr/lib/budgie-window-shuffler/tile_active maximize "id=$1"
    echo "${position} is invalid. Valid values are ${position_list}"
    exit 1

if [ -z "${pid}" ] || [ -z "${position}" ]
  echo "Usage: $0 pid position"
  echo "Valid positions: ${position_list}"
  exit 1

while IFS='' read -r line; do window_ids+=("$line"); done < <(xdotool search --pid "${pid}" --onlyvisible --sync)

if [ -z "${window_ids[0]}" ]; then
  echo "No window id found for pid ${pid}"
  exit 1

for windowid in "${window_ids[@]}"; do
  echo "Setting window ID: ${windowid} to position: '${position}'"
  set_position "${windowid}"

And then:

vlc "${video}" &
vlc "${video}" &
sleep 2
bash $pid1 left
bash $pid2 right

The sleep is needed because vlc player change its window size after loading the video.
Also, this solution doesn’t work with nemo, because the returned PID is not the one this a window ID.

Too complex! I wish you success with this new “window rules” feature. :slightly_smiling_face:

1 Like

In the meantime, finished the open_inposition module.
Usage: run the executable /usr/lib/budgie-window-shuffler/open_inposition with the arguments:

<command to open the window> <according wm_class> <xposition, yposition (in the grid), cols, rows (of the grid)>

optional arguments (after arguments above):

<xspan, yspan> 

Using xdotool can work, but is quite unclean and error prone.
I will push the module today or tomorrow. Then clone extras from github and compile.

An example:

To get this:


'/usr/lib/budgie-window-shuffler/open_inposition' nemo nemo 0 0 2 2 & '/usr/lib/budgie-window-shuffler/open_inposition' gedit gedit 0 1 2 2 & '/usr/lib/budgie-window-shuffler/open_inposition' 'firefox' firefox 1 0 2 2 1 2

I haven’t had a chance to download and compile this until today, but I absolutely love this! The amount you can fine tune all the window positions is absolutely incredible. For example, I was able to do this with ease: (maybe not the most practical use for nemo, but still, it shows the amazing level of control this update allows to open windows wherever you want them!)