Diff
1diff --git a/dot_config/i3/i3-autoname-workspaces.py b/dot_config/i3/i3-autoname-workspaces.py
2index 8175cbd41f0f7f141796f92894189763411ce3b2..d781fc28e8663cdb8b355c702cb703754b125b66 100644
3--- a/dot_config/i3/i3-autoname-workspaces.py
4+++ b/dot_config/i3/i3-autoname-workspaces.py
5@@ -4,15 +4,10 @@
6 # for running programs. It contains icons for a few programs, but more can
7 # easily be added by inserting them into WINDOW_ICONS below.
8 #
9-# Dependencies
10-# * xorg-xprop - install through system package manager
11-# * i3ipc - install with pip
12-# * fontawesome - install with pip
13+# Dependencies: xorg-xprop i3ipc fontawesome
14 #
15 # Installation:
16-# * Download this script and place it in ~/.config/i3/ (or anywhere you want)
17-# * Add "exec_always ~/.config/i3/i3-autoname-workspaces.py &" to your i3 config
18-# * Restart i3: "$ i3-msg restart"
19+# Add "exec_always ~/.config/i3/i3-autoname-workspaces.py &" to the i3 config
20 #
21 # Configuration:
22 # The default i3 config's keybingings reference workspaces by name, which is an
23@@ -23,7 +18,6 @@
24 # To:
25 # bindsym $mod+1 workspace number 1
26
27-
28 import re
29 import signal
30 import subprocess as proc
31@@ -69,6 +63,7 @@ WINDOW_ICONS = {
32 'jetbrains-studio': fa.icons['code'],
33 'kicad': fa.icons['microchip'],
34 'ksp.x86_64': fa.icons['space-shuttle'],
35+ 'ledger live': fa.icons['wallet'],
36 'libreoffice-calc': fa.icons['file-excel'],
37 'libreoffice-impress': fa.icons['file-powerpoint'],
38 'libreoffice-writer': fa.icons['file-alt'],
39@@ -85,6 +80,7 @@ WINDOW_ICONS = {
40 'qtcreator': fa.icons['code'],
41 'roxterm': fa.icons['terminal'],
42 'seahorse': fa.icons['lock'],
43+ 'simplescreenrecorder': fa.icons['video'],
44 'slack': fa.icons['slack'],
45 'spotify': fa.icons['spotify'],
46 'sqlitebrowser': fa.icons['database'],
47@@ -109,12 +105,15 @@ DEFAULT_ICON = '*'
48 # Returns a dictionary with the following keys: 'num', 'shortname', and 'icons'
49 # Any field that's missing in @name will be None in the returned dict
50 def parse_workspace_name(name):
51- match = re.match(r'(?P<num>\d+):?(?P<shortname>\w+)? ?(?P<icons>.+)?', name)
52+ match = re.match(
53+ r'(?P<num>\d+):?(?P<shortname>\w+)? ?(?P<icons>.+)?',
54+ name,
55+ )
56 return match.groupdict()
57
58
59-# Given a dictionary with 'num', 'shortname', 'icons', return the formatted name
60-# by concatenating them together.
61+# Given a dictionary with 'num', 'shortname', 'icons',
62+# return the formatted name by concatenating them together.
63 def construct_workspace_name(parts):
64 new_name = str(parts['num'])
65 if parts['shortname'] or parts['icons']:
66@@ -141,7 +140,7 @@ def xprop(win_id, property):
67 return re.findall('"([^"]+)"', prop)
68
69 except proc.CalledProcessError:
70- print("Unable to get property for window '%d'" % win_id)
71+ print(f'Unable to get property for window "{win_id}"')
72 return None
73
74
75@@ -153,7 +152,7 @@ def icon_for_window(window):
76 if cls in WINDOW_ICONS:
77 return WINDOW_ICONS[cls]
78
79- print('No icon available for: %s' % str(classes))
80+ print(f'No icon available for: {classes}')
81
82 return DEFAULT_ICON
83
84@@ -175,6 +174,7 @@ def rename_workspaces(i3):
85 new_name = construct_workspace_name(name_parts)
86 i3.command(f'rename workspace "{workspace.name}" to "{new_name}"')
87
88+
89 # rename workspaces to just numbers and shortnames.
90 # called on exit to indicate that this script is no longer running.
91 def undo_window_renaming(i3):
92@@ -182,7 +182,7 @@ def undo_window_renaming(i3):
93 name_parts = parse_workspace_name(workspace.name)
94 name_parts['icons'] = None
95 new_name = construct_workspace_name(name_parts)
96- i3.command('rename workspace "%s" to "%s"' % (workspace.name, new_name))
97+ i3.command(f'rename workspace "{workspace.name}" to "{new_name}"')
98
99 i3.main_quit()
100 sys.exit(0)