The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
0

Launch program floating

asked 2014-10-12 00:37:56 +0000

mikedmcfarland gravatar image

updated 2014-10-12 02:13:10 +0000

I am looking to be able to launch a program in float mode. However I also need the program to be able to not float when opened normally.

Very simliar to question: 4550, launch-in-floating-mode

(sorry for not linking, not enough karma to post links.), however I can't just match on an instance type, since I only want it to float sometimes. Specifically, I use sublime text to do text edits, as well as edit git commit messages. I'd like to have the git commits float (as to not disrupt my current layout).

Here's the xprop output from both examples

commit message

_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35652881 _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL _NET_WM_USER_TIME(CARDINAL) = 186414856 _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2200510 WM_CLIENT_LEADER(WINDOW): window id # 0x2200001 _NET_WM_PID(CARDINAL) = 23978 WM_LOCALE_NAME(STRING) = "en_US.UTF-8" WM_CLIENT_MACHINE(STRING) = "archbear" WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified minimum size: 536 by 27 window gravity: NorthWest WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST WM_CLASS(STRING) = "subl3", "Subl3" WM_ICON_NAME(STRING) = "~/.git/COMMIT_EDITMSG - Sublime Text (UNREGISTERED)" _NET_WM_ICON_NAME(UTF8_STRING) = "~/.git/COMMIT_EDITMSG - Sublime Text (UNREGISTERED)" WM_NAME(STRING) = "~/.git/COMMIT_EDITMSG - Sublime Text (UNREGISTERED)" _NET_WM_NAME(UTF8_STRING) = "~/.git/COMMIT_EDITMSG - Sublime Text (UNREGISTERED)

normal

_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35651905 _NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL _NET_WM_USER_TIME(CARDINAL) = 186449524 _NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2200140 WM_CLIENT_LEADER(WINDOW): window id # 0x2200001 _NET_WM_PID(CARDINAL) = 23978 WM_LOCALE_NAME(STRING) = "en_US.UTF-8" WM_CLIENT_MACHINE(STRING) = "archbear" WM_NORMAL_HINTS(WM_SIZE_HINTS): program specified minimum size: 536 by 27 window gravity: NorthWest WM_PROTOCOLS(ATOM): protocols WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST WM_CLASS(STRING) = "subl3", "Subl3" WM_ICON_NAME(COMPOUND_TEXT) = "_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35652881 • - Sublime Text (UNREGISTERED)" _NET_WM_ICON_NAME(UTF8_STRING) = "_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35652881 • - Sublime Text (UNREGISTERED)" WM_NAME(COMPOUND_TEXT) = "_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35652881 • - Sublime Text (UNREGISTERED)" _NET_WM_NAME(UTF8_STRING) = "_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 35652881 • - Sublime Text (UNREGISTERED)"

The only relevant difference I noticed was that the WM_NAME contained COMMIT_EDITMSG. However I'm unsure how to invoke floating enable on a partial name.

I also figured I might just edit the xproperties with xprop to solve my problem (and match on window_role), but, now after a few tries, I'm not even sure that's something you can reasonably do (I honestly don't have an understanding of these things). Running xprop -set window_role popup and clicking sublime caused this as output xprop: error: unsupported conversion for window_role. I'm also not entirely sure how I'd determine window Id of a newly launched window in order to alter its properties specifically.

Anyway, I was wondering if anyone has a solution. Preferably one I could use on other applications when needed, I'm alright with making separate shell scripts altering xprops for running an app in floating mode.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-10-12 02:51:09 +0000

mikedmcfarland gravatar image

Well, I apparently suck at reading documentation. So it was fairly straightforward to enable floating on a window with a particular title. Here's what the solution could look like

#!/bin/sh
/usr/bin/subl3 -n -w $@
i3-msg '[title="COMMIT_EDITMSG"] floating enable'

So, first launch subl3 with a new window (-n) and wait for file to close before exiting process (-w). Then msg i3 to have it float any windows containing the text COMMIT_EDITMSG in the title.

edit flag offensive delete link more

Comments

Note that there might be a race condition here (or when adapting this to other programs): if subl3 returns _before_ it created the X11 window, i3-msg may reach i3 first and your command doesn’t match the window that gets picked up by i3 just afterwards.

Michael gravatar imageMichael ( 2014-10-13 07:41:11 +0000 )edit

Question Tools

Stats

Asked: 2014-10-12 00:37:56 +0000

Seen: 570 times

Last updated: Oct 12 '14