nowe podejście
This commit is contained in:
98
.config/sway/bin/mysway.py
Executable file
98
.config/sway/bin/mysway.py
Executable file
@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Prosty demoninik do aktualizacji nazw workspace
|
||||
"""
|
||||
|
||||
from i3ipc import Connection, Event
|
||||
|
||||
i3 = Connection()
|
||||
|
||||
|
||||
def glyph(ws_number):
|
||||
"""
|
||||
Nazwy worspace
|
||||
"""
|
||||
# glyphs = ["", "", "", "", "", "", "", ""]
|
||||
glyphs = [
|
||||
".::term:::.",
|
||||
".:::web:::.",
|
||||
".:::work::.",
|
||||
".::((4))::.",
|
||||
".::debug::.",
|
||||
".::((6))::.",
|
||||
".::books::.",
|
||||
".::meets::.",
|
||||
".::music::.",
|
||||
".::mail:::."
|
||||
]
|
||||
try:
|
||||
return glyphs[ws_number - 1]
|
||||
except IndexError:
|
||||
return "?"
|
||||
|
||||
|
||||
def change_workspace_name(name):
|
||||
"""
|
||||
Zmiana nazwy
|
||||
"""
|
||||
try:
|
||||
pass
|
||||
except Exception:
|
||||
raise
|
||||
else:
|
||||
pass
|
||||
finally:
|
||||
pass
|
||||
|
||||
|
||||
def assign_generic_name(i3, e):
|
||||
"""
|
||||
i3 events
|
||||
"""
|
||||
try:
|
||||
if not e.change == 'rename': # avoid looping
|
||||
con = i3.get_tree().find_focused()
|
||||
if not con.type == 'workspace':
|
||||
if not e.change == 'new':
|
||||
is_floating = con.type == 'floating_con' or con.floating and '_on' in con.floating
|
||||
|
||||
# Tiling mode or floating indication. Change symbols if necessary.
|
||||
ws_old_name = con.workspace().name
|
||||
ws_name = "%s: %s " % (
|
||||
con.workspace().num, glyph(con.workspace().num))
|
||||
|
||||
i3.command('rename workspace "%s" to %s' %
|
||||
(ws_old_name, ws_name))
|
||||
else:
|
||||
# In sway we may open a new window w/o moving focus; let's give the workspace a name anyway.
|
||||
con = i3.get_tree().find_by_id(e.container.id)
|
||||
ws_num = con.workspace().num
|
||||
w_name = con.name if con.name else ''
|
||||
|
||||
if w_name and ws_num:
|
||||
name = "%s: %s\u00a0%s" % (
|
||||
ws_num, glyph(ws_num), w_name)
|
||||
i3.command('rename workspace "%s" to %s' %
|
||||
(ws_num, name))
|
||||
|
||||
else:
|
||||
# Give the (empty) workspace a generic name: "number: glyph" (like "1: ")
|
||||
ws_num = con.workspace().num
|
||||
ws_new_name = "%s: %s" % (ws_num, glyph(ws_num))
|
||||
|
||||
i3.command('rename workspace to "{}"'.format(ws_new_name))
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
# Subscribe to events
|
||||
i3.on(Event.WORKSPACE_FOCUS, assign_generic_name)
|
||||
i3.on(Event.BINDING, assign_generic_name)
|
||||
|
||||
i3.main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user