3

I'm using i3wm and Keepassx2 on an Arch-Linux installation. I configured i3 to automatically move a window with the window class "Keepassx2" to a certain workspace $WSKP. I also configured $mod+P to execute Keepassx2. Now I would like to write a custom script that is executed by $mod+P instead. This script should:

  • launch Keepassx2 when no other instance of it is currently running
  • maximize Keepassx2 and move focus to the specific workspace $WSKP when there already is a running instance

I want this because I don't need the Keepass-Workspace to be open all the time and it takes another unnecessary keypress when tabbing through the workspaces.

Checking whether there already is a running instance is easy:

if [ $(pidof keepassx2) ]; then 
    # maximize the running instance and move focus with i3-msg
fi;

But how do I accomplish maximizing the running instance?

herhuf
  • 255
  • 2
  • 10
  • If `Keepassx2` is running in its own workspace, isn't it maximized anyway? – pfnuesel Sep 06 '17 at 15:06
  • I forgot to add that - I would like to have it minimized per default so that it does not take up a workspace. Only when I need it. – herhuf Sep 06 '17 at 15:31
  • You cannot minimize or maximize a window in i3. Use tabbed mode. i3 has a hidden workspace to hide windows: https://i3wm.org/docs/userguide.html#_scratchpad – ctx Sep 06 '17 at 17:06

1 Answers1

2

i3 has no 'maximize' function, you want to focus your window and you might want to make the window fullscreen.

You can use this snipped:

winid="$(printf "%u\n" $windowid 2>/dev/null)
i3-msg "[id=\"$winid\"] "focus; fullscreen"

How you get the windowid from the pid is described in this question.

ctx
  • 2,404
  • 10
  • 17