This forum has been archived. All content is frozen. Please use KDE Discuss instead.

shortcut to create and name a new workspace or activity?

Tags: None
(comma "," separated)
pescobar
Registered Member
Posts
5
Karma
0
Hi,

I am looking for a way to optimize my workflow and how I organize the different tasks I use to do in parallel.

I think the perfect solution for me would be a keyboard shortcut to create a new workspace that when pressed asks for a name (usually the name of the task I plan to do in this workspace) and then it adds this new named workspace to my current list of workspaces and I move automatically to it. Another option would be to do the same but using kde activities instead of workspaces.

The problem I have is that I couldn´t find a way to do this quickly. If I want to add a new workspace this requires a few clicks and then another few clicks to name it. It´s the same for activities. My ideal solution would be the possibility to do ¨keyboard shortcut >> ask for name >> new workspace or activy created¨".

Does anyone knows a solution/workaround/suggestion for my problem?

thanks for your help.
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
Your workflow sounds very reasonable and exactly how I think activities should work. (My current setup functions in a very similar way using dynamic workspaces in xmonad.) Hopefully the new activity switcher will make creating new activities easier (poke poke ivan ;)).

I don't know the easiest solution to do this at the moment, so I wrote a script just for you:
Code: Select all
#!/bin/bash

tmpdir=/tmp/kde-"$USER"/

# Get list of old activities
qdbus org.kde.kactivitymanagerd /ActivityManager/Activities ListActivities > "$tmpdir"/old_activities

# Create new activity
new_activity=$(kdialog --inputbox "New activity name:")
qdbus org.kde.kactivitymanagerd /ActivityManager/Activities AddActivity "$new_activity"

# Get new activity GUID and switch to it
qdbus org.kde.kactivitymanagerd /ActivityManager/Activities ListActivities > "$tmpdir"/new_activities
guid=$(diff "$tmpdir"/old_activities "$tmpdir"/new_activities | tail -1 | cut -c 3-)
qdbus org.kde.kactivitymanagerd /ActivityManager/Activities SetCurrentActivity "$guid"


Note: I'm not the best scripter and the way I get the new activity GUID is pretty ugly. If anyone knows a better way, feel free to modify it. Use at your own risk etc.

To use it, copy the code to a text editor (e.g. KWrite), save it as add_activity.sh, right click on the file in Dolphin -> Properties -> Permissions and enable "Is executable". You can now click on the file to run the script. If it seems to work well, you can move it to some appropriate place and add a keybinding to it in System Settings -> Shortcuts & Gestures -> Custom Shortcuts -> Edit -> New -> Global Shortcut -> Command/URL. Set a trigger shortcut and browse to the script under Action.

The script requires qdbus, kdialog, (bash, tail, cut, diff). Most of those should be installed already, you may have to install the first two.

Let me know how it works for you!


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
pescobar
Registered Member
Posts
5
Karma
0
Thank you very much for your help Hans. This is exactly what I needed and in the first test I have just done it's working great :) I have to say I got surprised that KDE doesn't support this natively.

The activity switcher that you mention also looks really really nice. I will follow it's development for sure ;)

btw, do you know which would be the right qdbus command to create a new workspace instead of a new activity? I would like to modify your script to create workspaces instead of activities and test both approaches to see which works better for me. If you don't remember how to create workspaces I will dig a little bit in the documentation (I am a total noob with qdbus). And also, the scripts generates a new activity with dark desktop background, do you know if it's possible to use another background?

thanks again!
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
pescobar wrote:I have to say I got surprised that KDE doesn't support this natively.


Don't take my word for it though, I haven't used activities in a while so I'm not sure if it's changed or not.

btw, do you know which would be the right qdbus command to create a new workspace instead of a new activity? I would like to modify your script to create workspaces instead of activities and test both approaches to see which works better for me. If you don't remember how to create workspaces I will dig a little bit in the documentation (I am a total noob with qdbus).


Unfortunately I couldn't find it (I usually use qdbusviewer). I could move your topic to the KWin forum if you want, where the KWin developers are more likely to see your post and hopefully can answer your question. KWin also has support for scripting, which may (or may not) be more appropriate for solving your problem.

And also, the scripts generates a new activity with dark desktop background, do you know if it's possible to use another background?


Again, I unfortunately don't have an answer to that. Just from guessing I see two possible solutions/workarounds:
1. Change the default wallpaper somehow (change config file, replace the wallpaper file).
2. Change the wallpaper after creating the activity.

For option 2, you may be able to use Plasma Scripting. You could also try e.g. this script or similar ones.


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
pescobar
Registered Member
Posts
5
Karma
0
Hans wrote:
Unfortunately I couldn't find it (I usually use qdbusviewer). I could move your topic to the KWin forum if you want, where the KWin developers are more likely to see your post and hopefully can answer your question. KWin also has support for scripting, which may (or may not) be more appropriate for solving your problem.


if you think that can help it would be nice. Thanks for your help.
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
OK, moved. You can try to post a new topic about the default activity wallpaper in the Plasma forum. :)


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
luebking
Karma
0
1) install "wmctrl" (you got to send client messages and operating on xprop won't be fun anyway)

2) this will work with about every NETWM compliant WM

set amount of VDs to ... not 7 ;-)
Code: Select all
wmctrl -n 6


print current number of VDs
Code: Select all
wmctrl -d | wc -l


add a desktop
Code: Select all
wmctrl -n $((`wmctrl -d | wc -l` + 1))


add a desktop and move there
Code: Select all
NEW_DESK_COUNT=$((`wmctrl -d | wc -l` + 1)); wmctrl -n $NEW_DESK_COUNT; wmctrl -s $((NEW_DESK_COUNT-1))


remove a desktop
Code: Select all
wmctrl -n $((`wmctrl -d | wc -l` - 1))


you can also adjust the layout (rows/columns(, which is but accounted by only *some* pagers and notably not by many KWin effects (you cannot turn a grid into a dice. period. ;-)
also dealing with names is more tricky

both will require to xprop the root window and i don't know howto exactly (at hand, would have to try myself)

NOTICE: NONE OF THOSE CHANGES IS PERSISTENT, ie. they're gone when you restart kwin/KDE!
pescobar
Registered Member
Posts
5
Karma
0
Hi luebking,

thanks for your reply, right this morning I tried to do some testing with "wmctrl"

it works mostly for me, the only feature I miss is to rename workspaces and to delete workspaces by name.

I have been looking around the different possibilities to get my desired workflow with different desktop environments. By now, the one which seem to better fit my requirements out of the box is the cinnamon workspace switcher, which allows to easily add and rename workspaces and also delete them
http://itsfoss.com/workspace-linux-mint-16/

The only drawback from my point of view is that it doesn't allow to do it with keyboard shortcuts, but maybe writing an small cinnamon applet or extension is not that hard. Maybe I will give it a try....
luebking
Karma
0
xprop can't (properly) set lists of elements (at least i failed) so it's not possible to set the desktop name with it. KWin scripting doesn't allow this (so far) either so you'd need a tool written in eg. c++ (or even python?) to do this.

See http://api.kde.org/4.12-api/kdelibs-api ... ystem.html
resp. http://api.kde.org/4.12-api/kdelibs-api ... tInfo.html

Dealing with this is not very hard if you've experience with the KDE/Qt c++ API.

Notice that you cannot remove a random virtual desktop. You'll have to introduce this concept by lowering the amount and shifting virtual desktop assignment of all windows above (since former VD #4 is now VD #3)
luebking
Karma
0
Code: Select all
git clone https://github.com/luebking/KLItools.git
cd KLItools
./make_kwindowsystem.sh
./kwindowsystem help
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
luebking wrote:
Code: Select all
git clone https://github.com/luebking/KLItools.git
cd KLItools
./make_kwindowsystem.sh
./kwindowsystem help


Really cool stuff!

It would be nice if you added a script to change the current wallpaper, it seems like a often requested feature and I have yet to see it implemented in a nice way (i.e., without kquitapp plasma-desktop && sleep 0.1 && plasma-desktop or something similar).


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
luebking
Karma
0
Code: Select all
qdbus org.kde.be.shell /Desktop setWallpaper <path> [<mode>]
;-P

The plasma wallpaper containment only reparses the config on start and plasma does not seem to allow to reload individual components (nor autoreloads them on config change)
Faking a drop event fails because of the popup that asks whether to add an icon.

It's simply not designed to be fed from outside - but if it's a popular demand, I wonder why nobody just added the 3-4 LOC for a dbus interface. (Ok, maybe 10, if you like clean code ;-)

What *might* work would be to "cheat" on the slideshow mode by passing it the path to a dir containing a single symlink to the actual wallpaper and replace (with new name) that symlink and wait for the slideshow timeout.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The Slideshow plugin is the usual recommended workaround, and is known to work I believe as long as you use a different filename for the new wallpaper.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Hans
Administrator
Posts
3304
Karma
24
OS
luebking wrote:
Code: Select all
qdbus org.kde.be.shell /Desktop setWallpaper <path> [<mode>]
;-P


Woah, I didn't know that there was a dbus call for that, awesome!

It's simply not designed to be fed from outside - but if it's a popular demand, I wonder why nobody just added the 3-4 LOC for a dbus interface. (Ok, maybe 10, if you like clean code ;-)


Probably because it's mostly users that are asking. Personally I don't need it, but to me it seems like a reasonable feature that would help a lot of people.


Problem solved? Please click on "Accept this answer" below the post with the best answer to mark your topic as solved.

10 things you might want to do in KDE | Open menu with Super key | Mouse shortcuts
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
If I recall, it was suggested at one point but objections were raised over making an API specific to one form of wallpaper - namely the Image wallpaper.
A generic call was proposed but i'm not sure what happened to that. One of the Plasma developers is probably more aware of why that didn't happen.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], q.ignora, watchstar