mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-24 18:58:33 +02:00
i3-companion: add an icon with the layout of the focused container
This commit is contained in:
parent
318cc1e713
commit
41705ca492
3 changed files with 43 additions and 18 deletions
|
@ -80,6 +80,10 @@ icons = {
|
||||||
"headset": icon(2, ""),
|
"headset": icon(2, ""),
|
||||||
"keyboard": icon(2, "⌨"),
|
"keyboard": icon(2, "⌨"),
|
||||||
"laptop": icon(2, "💻"),
|
"laptop": icon(2, "💻"),
|
||||||
|
"layout-splith": icon(2, ""),
|
||||||
|
"layout-splitv": icon(2, ""),
|
||||||
|
"layout-stacking": icon(2, ""),
|
||||||
|
"layout-tabbed": icon(2, ""),
|
||||||
"loudspeaker": icon(2, ""),
|
"loudspeaker": icon(2, ""),
|
||||||
"microphone": icon(2, ""),
|
"microphone": icon(2, ""),
|
||||||
"mouse": icon(2, ""),
|
"mouse": icon(2, ""),
|
||||||
|
@ -235,7 +239,7 @@ def debounce(sleep, *, unless=None):
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def polybar(module):
|
def polybar(module, silent=False):
|
||||||
"""Use returned string to update polybar module"""
|
"""Use returned string to update polybar module"""
|
||||||
|
|
||||||
def decorator(fn):
|
def decorator(fn):
|
||||||
|
@ -259,7 +263,8 @@ def polybar(module):
|
||||||
if e.errno != errno.ENXIO:
|
if e.errno != errno.ENXIO:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
logger.info(f"polybar/{module}: content updated")
|
log = logger.debug if silent else logger.info
|
||||||
|
log("polybar/%s: content updated", module)
|
||||||
cache[module] = content
|
cache[module] = content
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
@ -587,6 +592,18 @@ async def workspace_info(i3, event):
|
||||||
workspace_info.last_id = result[0]
|
workspace_info.last_id = result[0]
|
||||||
|
|
||||||
|
|
||||||
|
@on(I3Event.WINDOW_FOCUS, CommandEvent("layout-changed"), StartEvent)
|
||||||
|
@polybar("i3layout", silent=True)
|
||||||
|
async def layout_update(i3, event):
|
||||||
|
"""Display layout of the current focused container."""
|
||||||
|
tree = await i3.get_tree()
|
||||||
|
focused = tree.find_focused()
|
||||||
|
if not focused:
|
||||||
|
return ""
|
||||||
|
layout = focused.parent.layout
|
||||||
|
return icons.get(f"layout-{layout}", icons['unknown'])
|
||||||
|
|
||||||
|
|
||||||
@on(I3Event.OUTPUT, StartEvent)
|
@on(I3Event.OUTPUT, StartEvent)
|
||||||
@static(last_setup=None)
|
@static(last_setup=None)
|
||||||
@debounce(2)
|
@debounce(2)
|
||||||
|
@ -930,12 +947,13 @@ async def main(options):
|
||||||
# this mechanism as an IPC mechanism. The alternative would be
|
# this mechanism as an IPC mechanism. The alternative would be
|
||||||
# to use ticks but we would need to spawn an i3-msg process
|
# to use ticks but we would need to spawn an i3-msg process
|
||||||
# for that.
|
# for that.
|
||||||
cmd = event.binding.command
|
for cmd in event.binding.command.split(";"):
|
||||||
|
cmd = cmd.strip()
|
||||||
if not cmd.startswith("nop "):
|
if not cmd.startswith("nop "):
|
||||||
return
|
continue
|
||||||
cmd = cmd[4:].strip(" \"'")
|
cmd = cmd[4:].strip(" \"'")
|
||||||
if not cmd:
|
if not cmd:
|
||||||
return
|
continue
|
||||||
kind = cmd.split(":")[0]
|
kind = cmd.split(":")[0]
|
||||||
for fn, events in on.functions.items():
|
for fn, events in on.functions.items():
|
||||||
for e in events:
|
for e in events:
|
||||||
|
|
4
config
4
config
|
@ -73,8 +73,8 @@ bindsym $mod+f fullscreen toggle
|
||||||
bindsym $mod+Shift+f fullscreen toggle global
|
bindsym $mod+Shift+f fullscreen toggle global
|
||||||
|
|
||||||
# change container layout (tabbed, toggle split)
|
# change container layout (tabbed, toggle split)
|
||||||
bindsym $mod+w layout toggle splitv splith tabbed
|
bindsym $mod+w layout toggle splitv splith tabbed; nop "layout-changed"
|
||||||
bindsym $mod+v split toggle
|
bindsym $mod+v split toggle; nop "layout-changed"
|
||||||
|
|
||||||
# toggle tiling / floating
|
# toggle tiling / floating
|
||||||
bindsym $mod+Shift+space floating toggle
|
bindsym $mod+Shift+space floating toggle
|
||||||
|
|
|
@ -4,6 +4,7 @@ background = #c0000000
|
||||||
foreground = #eaeaea
|
foreground = #eaeaea
|
||||||
highlight = #4c7899
|
highlight = #4c7899
|
||||||
warning = #ff3121
|
warning = #ff3121
|
||||||
|
focused = #cc5c00
|
||||||
transparent = #00000000
|
transparent = #00000000
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
|
@ -29,7 +30,7 @@ font-0 = Iosevka Aile:style=Regular:size=10;2
|
||||||
font-1 = Font Awesome 6 Pro:style=Solid:size=10;2
|
font-1 = Font Awesome 6 Pro:style=Solid:size=10;2
|
||||||
font-2 = Font Awesome 6 Brands:style=Regular:size=10;2
|
font-2 = Font Awesome 6 Brands:style=Regular:size=10;2
|
||||||
|
|
||||||
modules-left = i3
|
modules-left = i3 i3layout
|
||||||
modules-center = date
|
modules-center = date
|
||||||
|
|
||||||
[bar/alone]
|
[bar/alone]
|
||||||
|
@ -55,7 +56,7 @@ pin-workspaces = true
|
||||||
label-mode-background = ${colors.highlight}
|
label-mode-background = ${colors.highlight}
|
||||||
label-mode-padding = 1
|
label-mode-padding = 1
|
||||||
label-focused = %name%
|
label-focused = %name%
|
||||||
label-focused-background = #cc5c00
|
label-focused-background = ${colors.focused}
|
||||||
label-focused-padding = 1
|
label-focused-padding = 1
|
||||||
label-unfocused = %name%
|
label-unfocused = %name%
|
||||||
label-unfocused-padding = 1
|
label-unfocused-padding = 1
|
||||||
|
@ -66,6 +67,12 @@ label-urgent = %name%
|
||||||
label-urgent-background = #a00000
|
label-urgent-background = #a00000
|
||||||
label-urgent-padding = 1
|
label-urgent-padding = 1
|
||||||
|
|
||||||
|
[module/i3layout]
|
||||||
|
type = custom/ipc
|
||||||
|
hook-0 = cat $XDG_RUNTIME_DIR/i3/i3layout.txt 2> /dev/null
|
||||||
|
format-foreground = ${colors.focused}
|
||||||
|
initial = 1
|
||||||
|
|
||||||
# This needs 3.6+
|
# This needs 3.6+
|
||||||
[module/disk]
|
[module/disk]
|
||||||
type = internal/fs
|
type = internal/fs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue