Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-08-10 13:53:22

ranoutofusernames
Member
Registered: 2016-05-11
Posts: 12

Any option on settings workspaces from the cli?

Sometimes I find myself needing extra workspaces, however going to the workspaces screen and change it from the gui is tedious.

I found it's called "xfwm4-workspace-settings", however manual search returns the xfwm4 manual.

Running xfwm4 --help-all returns:

xfwm4 --help-all
Usage:
  xfwm4 [OPTION…] [ARGUMENTS...]

Help Options:
  -h, --help                   Show help options
  --help-all                   Show all help options
  --help-gtk                   Show GTK+ Options
  --help-sm-client             Show session management options

GTK+ Options
  --class=CLASS                Program class as used by the window manager
  --name=NAME                  Program name as used by the window manager
  --screen=SCREEN              X screen to use
  --sync                       Make X calls synchronous
  --gtk-module=MODULES         Load additional GTK+ modules
  --g-fatal-warnings           Make all warnings fatal

Session management options
  --sm-client-id=ID            Session management client ID
  --sm-client-disable          Disable session management

Application Options:
  --daemon                     Fork to the background
  --compositor=on|off|auto     Set the compositor mode
  --replace                    Replace the existing window manager
  -V, --version                Print version information and exit
  --display=DISPLAY            X display to use

Searching the forum returns a result from 2007 mentioning xdotool, however it has its own quirks.

Anyone got a better solution for this?

I'm interested in increasing/decreasing workspace amount from the cli.

Example:

whatever-workspace-command +1

or

whatever-workspace-command -1

or

whatever-workspace-command --amount 6

Offline

#2 2016-08-10 14:01:30

ranoutofusernames
Member
Registered: 2016-05-11
Posts: 12

Re: Any option on settings workspaces from the cli?

I'm too dumb to read strace output.

Plus opening the window with strace, moving the mouse to position and increasing the workspace amount by 2, closing it created 16229 lines.

This is the search result:

http://forum.xfce.org/viewtopic.php?id=3605

Last edited by ranoutofusernames (2016-08-10 14:05:50)

Offline

#3 2016-08-10 14:07:18

ranoutofusernames
Member
Registered: 2016-05-11
Posts: 12

Re: Any option on settings workspaces from the cli?

Offline

#4 2016-08-10 15:44:37

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,494

Re: Any option on settings workspaces from the cli?

You can use xfconf-query to show and set the number of workspaces.

To show the current number of workspaces:

xfconf-query -c xfwm4 -p /general/workspace_count

To set a number of workspaces:

xfconf-query -c xfwm4 -p /general/workspace_count -s <NUM>

...where <NUM> is a numberic value.

What this doesn't do is:
- increase/decrease the number of workspaces by a value
- set/change the workspace names
If these are requirements, you'll need to write some sort of wrapper script.

Edit: If you need to add or remove one workspace, you can set a keyboard shortcut for that. Go to Settings Manager > Window Manager > Keyboard and set shortcuts for "Add workspace", "Add adjacent workspace", "Delete last workspace", "Delete active workspace".


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2016-08-10 19:48:29

ranoutofusernames
Member
Registered: 2016-05-11
Posts: 12

Re: Any option on settings workspaces from the cli?

If these are requirements, you'll need to write some sort of wrapper script.

Thanks toz, just done that.

Not the best, but seems to work fine if $1 is kept to an integer, or +integer and -integer.

The python code will thow errors if someone tries to add 5.6 workspaces for example.

Works like:

$0 +5 - increase xfce workspace count by 5. Eg from 2 to 7.

$0 -2 - decrease xfce workspace count by 2. Eg from 7 to 5.

$0 8 - set xfce workspace count to 8. Eg from 5 to 8.

#!/bin/bash
# modify xfce workspace count
# xfconf-query -c xfwm4 -p /general/workspace_count

if [ -z $1 ];then
echo "First arg was empty. Exiting."
cat << EOF
Usage of $0:

$0 +5 - increase xfce workspace count by 5. Eg from 2 to 7.

$0 -2 - decrease xfce workspace count by 2. Eg from 7 to 5.

$0 8 - set xfce workspace count to 8. Eg from 5 to 8.
EOF
exit
fi


count="$(xfconf-query -c xfwm4 -p /general/workspace_count)"
# modifier to new count
newcountplus()
{
xfconf-query -c xfwm4 -p /general/workspace_count -s ${newstring}
}

newcountminus()
{
xfconf-query -c xfwm4 -p /general/workspace_count -s ${newstring2}
}

newcountnormal()
{
xfconf-query -c xfwm4 -p /general/workspace_count -s $1
}

# try to filter out + and - from the first arguement with cut
string="$(echo $1 | cut -c2-3)"

if [ -z ${string} ];then
string=0
fi

# check for python2
python --version &> /tmp/py2
# if python 2 string isn't found in /tmp/py2 then try python2 executable
if ! grep -qs "Python 2" /tmp/py2;then
rm /tmp/py2
python2 --version &> /tmp/py2
fi

# check for python3
python3 --version &> /tmp/py3

if grep -qs "Python 2" /tmp/py2;then
py2ok="yes"
rm /tmp/py2
fi

if grep -qs "Python 3" /tmp/py3;then
py3ok="yes"
rm /tmp/py3
fi

# modify $str with python to an integer(eg 2 or 5)
# use python3 first
if [ "${py3ok}" = yes ];then
newstring="$(python3 -c "num = int('${string}');print(num + ${count})")"
newstring2="$(python3 -c "num = int('${string}');print(${count} - num)")"
else

# else use python2 if it exists
if [ "${py2ok}" = yes ];then
newstring="$(python -c "num = int("${string}");print num + ${count}")"
newstring2="$(python -c "num = int('${string}');print ${count} - num")"
fi

fi

case $1 in
+*)
# plus increase
newcountplus
exit
;;
-*)
# minus decrease
newcountminus
exit
;;
*)
# else modify to new count
newcountnormal $1
;;
esac

Last edited by ranoutofusernames (2016-08-10 19:50:54)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 537.9 KiB (Peak: 539.18 KiB) ]