You are not logged in.

#1 2017-12-11 20:49:37

jfk
Member
Registered: 2017-12-11
Posts: 81

Command "show app from tray / minimize to tray"

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

#2 2017-12-11 21:14:37

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Command "show app from tray / minimize to tray"

man wmctrl

No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-12-11 21:30:55

jfk
Member
Registered: 2017-12-11
Posts: 81

Re: Command "show app from tray / minimize to tray"

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

#4 2017-12-11 21:44:16

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: Command "show app from tray / minimize to tray"

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

#5 2017-12-11 22:03:09

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: Command "show app from tray / minimize to tray"

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

#6 2017-12-11 23:01:07

jfk
Member
Registered: 2017-12-11
Posts: 81

Re: Command "show app from tray / minimize to tray"

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

#7 2017-12-11 23:46:02

robg
Member
Registered: 2015-03-05
Posts: 218

Re: Command "show app from tray / minimize to tray"

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

#8 2017-12-11 23:57:11

jfk
Member
Registered: 2017-12-11
Posts: 81

Re: Command "show app from tray / minimize to tray"

Robg, yes, I thought about this but get the same behavior with chromium for instance which simply executes "chromium %U".

Offline

#9 2017-12-12 07:09:04

seth
Member
Registered: 2012-09-03
Posts: 51,229

Re: Command "show app from tray / minimize to tray"

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

Board footer

Powered by FluxBB