Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-01-09 16:27:56

Skaperen
Member
From: surface of planet Earth
Registered: 2013-06-15
Posts: 322

it would be nice to have ...

... a script that i could run that would:

    1.  add another workspace
    2.  update all workspace switchers to show it
    3.  move all windows in all workspaces to the next higher workspace (the big shift)
    4.  switch to workspace 0 (now empty)
    5.  open the designated program window (terminal, browser, whatever) in workspace 0

i could then make some nice launchers and not need to keep so many empty workspaces ready to go.

Offline

#2 2019-01-09 20:46:01

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,384

Re: it would be nice to have ...

Challenge accepted!

#!/bin/bash
#
# Requires: wmctrl
# Notes: $1 is the executable name of the application to start

# get current workspace number & state of the windows
CURRWS=$(xfconf-query -c xfwm4 -p /general/workspace_count)
CURRSTATE=$(wmctrl -l > ~/.cache/.wsstate)

# add a new workspace
xfconf-query -c xfwm4 -p /general/workspace_count -s $(( $(xfconf-query -c xfwm4 -p /general/workspace_count) + 1 ))

# move all existing windows up a workspace
for (( x=0; x<$CURRWS; x++ ))
do
	for app in $(cat ~/.cache/.wsstate | awk '{print $1" "$2}' | grep " $x" | awk '{print $1}')
	do
		wmctrl -ir $app -t $(( $x + 1 ))
	done
done

# go to the first workspace
wmctrl -s 0

# start the executable that was given as a parameter to the script
exec $@

Save the file locally, make it executable and call it like this:

SCRIPTNAME EXECUTABLE

...where SCRIPTNAME is the name that you have the script and EXECUTABLE is the name of program that you want to start in workspace 0. For example:

/home/toz/bin/wslauncher xfce4-terminal

Offline

#3 2019-01-10 00:42:38

Skaperen
Member
From: surface of planet Earth
Registered: 2013-06-15
Posts: 322

Re: it would be nice to have ...

nice!  thanks!  that is also the way i like to learn new things, by example.  while i already know programming, including with bash, it is accessing the desktop environment that is new to me.

Offline

Board footer

Powered by FluxBB