You are not logged in.
I'd like to find a command to mimic the behavior of my mouse clicking on an app from the tray (Plasma 5): to get a window of the app running and then closing it to tray. This is for a keyboard shortcut.
When I simply run the app (in that case):
flatpak run
a new instance of the app adds up each time on the taskbar.
Offline
Offline
Thanks, I had already tried wmctrl. If I'm not mistaken, it only interacts with the active windows. At least
wmctrl -l
only works that way. In my case I need the window to pop up from a background runing app.
Last edited by jfk (2017-12-11 21:32:14)
Offline
You're mistaken (in that wmctrl is no way restricted to active windows, but it requires a WM) but what you want to do does not exist as a concept - there is no "minimize to tray". The window is then closed and (typically) destroyed by the client and re-created when you click the icon, the technical details vary largely between the client toolkits and there're at least 3 systray protocols.
You can use xdotool to windowunmap a window, it will seem lost to the WM and taskbar (until you windowmap it), but that won't get you a systray icon nor will it save considerable resources.
Offline
Perhaps you can clarify jfk, it seems I interpreted your question very differently from the others above. I thought you wanted a run-or-raise type behavior. You already have the icon in the sys tray that starts the program, right? You just want to ensure that if you click on that icon many times, only a single instance is created: if it's already running the window is just raised (and "unminimized" if necessary). Is this correct?
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Trilby, that is almost correct. When I click on the tray icon, I get the desired behavior (window pops up at click1, then closes/minimize to tray at click2). However, when I click on the taskbar icon (which executes "flatkpak run"), I get each time a new instance.
I tried to deepen seth's idea to call xdotool with
xdotool search --name telegram windowmap
There're two issues: 1. It doesn't display the window (I got the tile on the taskbar but not the window) but most importantly 2. I obviously can't unmap it with the same command.
In Mint Cinnamon I had no issue setting that desired shortcut simply by running the app (Telegram %U).
Offline
Just to clarify one more thing, you are running the application using the `flatpak run $applicationname` command?
If this is the case why don't you try to run the AUR client for telegram? If this works as expected, you know where your issue lies.
Offline
Robg, yes, I thought about this but get the same behavior with chromium for instance which simply executes "chromium %U".
Offline
I've zero knowledge about flatpak pitfalls but will leave this code pattern as a lead
ACTIVE_NAME="`xdotool getactivewindow getwindowname`"
([ "$ACTIVE_NAME" = "STROGG" ] && xdotool search --onlyvisible --name '^STROGG$' windowunmap >/dev/null 2>&1) || \
xdotool search --name '^STROGG$' windowmap windowactivate >/dev/null 2>&1 || \
xterm -rv -title STROGG -xrm 'xterm.*.allowTitleOps:false' &
Offline