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

Editing the context menu of Panel application buttons

Tags: None
(comma "," separated)
diem
Registered Member
Posts
8
Karma
0
Hi all,

I would like to know whether it is possible to configure the Actions section of the context menu displayed when we right-click on the buttons representing running application windows on the Panel. Here's a picture of what I'm talking about:

Image

I have done extensive searching online and in these forums and the closest I seem to get is that one can edit the content of file context menus by editing .desktop files stored in ~/.local/share/kservices5/ServiceMenus/, but it seems I need to go a little deeper than that because those files don't affect these menus. I've also gone spelunking in /usr but not yet found anything helpful. Sure, I could dive into code/compilation but before I go to that level I would like to ascertain whether these menus contents are built from textual configuration files that I could edit.

To be more specific, what I would like to do is move the 'Move' action from the 'More..' submenu back up onto the main menu; I have a multi-monitor setup and the monitors are shared with multiple computers - I often switch just one to my Linux machine and would like to move a window from one of the other monitors to the one I have switched without being able to see the window frame to be able to grab it visually. Yes, very specific use case hence why I'm not raising a feature request ;D

Does anyone have any pointers? Either the config files themselves or even the code that builds Panel application buttons such that I could follow my nose to find how the context menu contents are constructed?

Thanks,

Ian
dzon
Registered Member
Posts
493
Karma
3
Clearly not extensive enough. There are posts about that here. I'll repeat. If you want additional entries ( or move them around) in right click menus, you need to edit the desktop application in /usr/share/applications. Add actions. Like so:
[Desktop Action Whatever]
Name=Whatever
Icon=optional
Exec=Whatever
And make sure it is listed under Actions= in that same file.
How you list them and where you put the Actions will define the place of them within the right click menu.
Here's an example with Konsole. https://imgur.com/a/BzkzrhS
I'm not sure what specific application you're talking about though.
You could probably create such a file in ~/.local/share/applications too, but personally I just keep a backup of such an edited file in case an update resets it.


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
diem
Registered Member
Posts
8
Karma
0
Thanks for responding Dzon, but I don't think you've quite understood what I'm asking.

I did find a fair few posts concerning how to alter the context menu of a specific application, but if you look at the screenshot I took, the Actions I've circled are those added to every application's context menu by default. It is these I would like to edit such that all applications context menus benefit from the single change. I don't want to have to add the action to every single application individually! D' you see what I'm getting at?

Cheers,

Ian
dzon
Registered Member
Posts
493
Karma
3
I wasn't really sure because I can not open your screenshot.
I think I get what you're aiming for. I tried something else before. But for now I only have it working in Dolphin, as a service menu. The move function that is.
Maybe I'll figure it out...one day. https://imgur.com/a/UjDBp5I


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
dzon
Registered Member
Posts
493
Karma
3
Hey, I might have something. There's a widget called Configurable button. https://store.kde.org/p/1297839. It allows you to run a script.
What I've done is the following:
1) create a key combo for the move window in system settings. In my case, I set it to alt+q
2) you need xdotool for this, install it ( I use that stuff for god knows how many things, a zillion..)
3) create a script like:
#!/bin/bash
xdotool key alt+q
4) make it executable
5) put the button widget on your panel and point the executables to that script.
You now no longer need to right click an application, go through the more actions for the move action.
The button in the screenshot is right between the active window close button and Brave icon on the panel.
https://imgur.com/a/edkWtAs
Ps: I'm sure there's some qdbus or whatever command for windowmove, but I don't know what it is. This method makes it possible though. However, there's a slight..glitch. I think it's a kde bug. Whereas move from the contextmenu keeps the window within the screen borders, the same windows move command by key bindings doesn't. That is, you can drag a window UNDER the panel. If you do the move by using the contextmenu, it doesn't. Fair "warning". Other than that, it works a charm.


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
dzon
Registered Member
Posts
493
Karma
3
And btw. You don't really need a widget for it. You could make an application and put that on your panel.
https://imgur.com/a/bbinjhu


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
diem
Registered Member
Posts
8
Karma
0
Thanks for the workaround dzon, unfortunately I haven't been able to make it work yet :(

I've created a Customizable Button widget that runs the script you suggest, but the alt+q seems to be fed to the application as text and doesn't initiate a move action. 'Move' on the Actions menu doesn't have a keyboard shortcut assigned, but then again I don't see how to assign one, so I'm stumped as to how to associate Alt+Q with Move - what am I missing?

Many thanks,

Ian
dzon
Registered Member
Posts
493
Karma
3
System settings>key shortcuts>kwin>move window>assign key combo.Menu>edit applications (ps, gimme some credit, dutch speaking)>pick a section (let's pick system)>tick one in there>create new>name it >executable command should be xdotool key (combo you made).
Like I said, you don't need the widget at all. If you just make an application, you can pin that to your panel.
If you prefer that particular widget, you need to create an executable script first of course. Point the two executables in that widget to that script.
But why bother. The application does exactly the same. Provided you have xdotool installed that is. https://imgur.com/a/n0tGzKj
From what you posted, I can only assume you didn't make the script executable. Again, creating an application is easier. Works really well.


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
dzon
Registered Member
Posts
493
Karma
3
Assigning a key combo is straight forward. https://imgur.com/a/QvdTKT2
Once the application is made, you put it on your panel. https://imgur.com/a/Ev0nPs3


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.
diem
Registered Member
Posts
8
Karma
0
Okay nice! I got it working. That's pretty cool - thanks for the workaround! And also thanks for introducing me to xdotool - I can see it being useful for all sorts of automation. I might keep digging to see if I can edit the Task Manager application button context menu for the hell of it, but at least if I fail now it won't matter ;D
dzon
Registered Member
Posts
493
Karma
3
Xdotool is one of those little things.....you wouldn't believe what you can achieve with it. My openbox setups are looooaded with it. On my kde I use it, for example, to create custom service menus and the likes. Just type xdotool --help in a terminal. You'll get an idea.
Btw, you can also combine things with it. As an example a couple of lines of my openbox autostart:
sleep 1 && xdotool behave_screen_edge top-left exec xdotool key exec skippy-xd &
sleep 1 && xdotool behave_screen_edge bottom-left exec xdotool key ctrl+d &
sleep 3 && xdotool behave_screen_edge top-right exec xdotool key alt+F4 &
sleep 1 && xdotool behave_screen_edge bottom-right exec xdotool key alt+q &
#sleep 1 && xdotool behave_screen_edge top-left mousemove 32 25 click 3 &
So besides the special command options, just keep in mind that, if an application has a shortcut ( by default or assigned) you can emulate it. And if you can emulate it, you can make pretty much anything you like.
Here's such an example in Dolphin. https://imgur.com/a/C6LjDXQ


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.


Bookmarks



Who is online

Registered users: bancha, Bing [Bot], Google [Bot], Sogou [Bot]