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 2014-05-12 07:39:08 +0000

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.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2014-05-12 17:20:37 +0000

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
edit flag offensive delete link more

Comments

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

Adaephon gravatar imageAdaephon ( 2014-05-13 07:20:57 +0000 )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 ( 2014-05-13 07:49:04 +0000 )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 ( 2014-05-13 15:31:45 +0000 )edit
3

answered 2014-05-12 08:00:28 +0000

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
edit flag offensive delete link more

Comments

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

FSund gravatar imageFSund ( 2014-05-12 08:05:20 +0000 )edit
2

answered 2014-05-12 08:51:56 +0000

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-05-12 07:39:08 +0000

Seen: 1,389 times

Last updated: May 12 '14