aboutsummaryrefslogtreecommitdiffstats
path: root/herbstluftwm/.config/herbstluftwm/floating.sh
blob: 403259d65e7ad91009b3019b5fd30aa22fee7ff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash

monitor=floatmon
tag=fl
Mod=${Mod:-Mod1}
Floatkey=${Floatkey:-Shift-f}

hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;}

size=$(herbstclient list_monitors | grep '\[FOCUS\]' | grep -oe '[0-9]\+x[0-9]\++[0-9]\++[0-9]\+')
echo "size is: $size"

hc chain , add "$tag" , floating "$tag" on
hc or , add_monitor "$size" "$tag" "$monitor" \
      , move_monitor "$monitor" "$size"
hc raise_monitor "$monitor"
hc lock_tag "$monitor"

cmd=(
or  case: and
        # if not on floating monitor
        . compare monitors.focus.name != "$monitor"
        # and if a client is focused
        . get_attr clients.focus.winid
        # then remember the last monitor of the client
        . chain try new_attr string clients.focus.my_lastmon
                try true
        . substitute M monitors.focus.index
            set_attr clients.focus.my_lastmon M
        # and then move the client to the floating tag
        . shift_to_monitor "$monitor"
        . focus_monitor "$monitor"
        . true
    case: and
        # if on the floating monitor
        . compare monitors.focus.name = "$monitor"
        # and if a client is focused
        . get_attr clients.focus.winid
        # then send it back to the original monitor
        . substitute M clients.focus.my_lastmon chain
            , shift_to_monitor M
            , focus_monitor M
        . true
    case: and
        # if the previous things fail,
        # just move to the first monitor
        . shift_to_monitor 0
        . focus_monitor 0
)

hc keybind $Mod-$Floatkey "${cmd[@]}"