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

Hotkey for opening floating terminal

asked May 12 '14

FSund gravatar image

Is there any way to make a hotkey that opens a terminal in floating mode?

I have $mod Mod4 set to open regular terminals (which are tiled/non-floating by default), and would like to have for example $mod+shift Mod4 open a terminal in floating mode.

3 answers

Sort by » oldest newest most voted
2

answered May 12 '14

KJ44 gravatar image

Here's a worked example of what badboy_ suggested

# Scratchpad terminal.
# https://faq.i3wm.org/question/2420/dropdown-terminal-in-i3/
# Using a custom title string with criteria is deliberate and keeps things simple.
exec --no-startup-id terminator -l KJ -T "Life is beautiful."
for_window [instance="terminator" title="Life"] floating enable, move scratchpad, scratchpad show;
for_window [instance="terminator" title="Life"] resize grow left 300, resize grow right 300, resize grow down 150, resize grow up 100, move scratchpad;
bindsym Menu  [instance="terminator" title="Life"] scratchpad show
bindsym Print [instance="terminator" title="Life"] scratchpad show

Comments

`floating enable` should not ne be necessary, as `move scratchpad` automatically enables floating.

Adaephon gravatar imageAdaephon (May 13 '14)edit

Thanks, this worked well. I removed the resize commands, since my terminal seems to have a weird size at startup, but I never restart my machine anyway, so I'll just resize the terminal manually when needed. They should implement a "set size" command, in addition to the resize command.

FSund gravatar imageFSund (May 13 '14)edit

Thanks Adaephon for the floating enable correction. Regarding the absolute setting of floating window size, see https://faq.i3wm.org/question/3727/how-to-resize-container-to-a-predefined-size/

KJ44 gravatar imageKJ44 (May 13 '14)edit
3

answered May 12 '14

badboy_ gravatar image

There are different solutions:

  1. You could use the scratchpad, and use a script to check if a scratchpad terminal is already opened or open one.
  2. Give your terminal a special instance name and use for_window to make it floating

Comments

Interesting, I've never heard of the scratchpad before. I'll do some testing!

FSund gravatar imageFSund (May 12 '14)edit
2

answered May 12 '14

Adaephon gravatar image

With xterm, roxterm and probably most other gtk-based terminal emulators you can change the class of the window with --class CLASSNAME. Use this to separate between floating and tiled windows:

for_window [class="FXTerm"] floating enable
bindsym $mod+Mod4 exec xterm
bindsym $mod+Shift+Mod4 exec xterm --class FXTerm

(This may also work with some other terminal emulators, but probably not with rxvt)

In i3 floating is an attribute that can be attributed to a window only after it has been created. It cannot be passed as parameter to exec and chaining exec and floating enable in a single command is unreliable because of timing issues.

for_window can be used execute commands for a certain windows (depending on their title, class or a few other parameters). Aside from changing the class, you could set a title, but many shell configurations try to change the terminal title, so there could be some timing issues there.

Changing the class has the possible drawback (advantage?) that some X Resources (usually defined in ~/.Xresources or ~/.Xdefaults) may have to be changed to work with the new class.

Question Tools

Stats

Asked: May 12 '14

Seen: 1,389 times

Last updated: May 12 '14