Compare commits

..

No commits in common. "bc10869bca1683958bb2990e4c563e56b0b922d9" and "617b11268d17560f14e644eae9f5401f23b2b6a4" have entirely different histories.

2 changed files with 30 additions and 82 deletions

View file

@ -24,7 +24,7 @@ bindsym $mod+Shift+q exec --no-startup-id ~/.config/i3/cursor.sh kill
bindsym $mod+space exec --no-startup-id i3-dmenu-desktop --dmenu='rofi -dmenu -i -font "Ubuntu 20"' bindsym $mod+space exec --no-startup-id i3-dmenu-desktop --dmenu='rofi -dmenu -i -font "Ubuntu 20"'
# lock the desktop # lock the desktop
bindsym $mod+l exec --no-startup-id i3lock -c 000000 -i "/home/sijmen/Pictures/uncharted4.png" -l bindsym $mod+l exec --no-startup-id dm-tool lock
# alternatively, you can use the cursor keys: # alternatively, you can use the cursor keys:
bindsym $mod+Left exec --no-startup-id ~/.config/i3/cursor.sh focus left bindsym $mod+Left exec --no-startup-id ~/.config/i3/cursor.sh focus left

View file

@ -21,75 +21,36 @@ import re
# (WM_CLASS) names and the icons can be any text you want to display. However # (WM_CLASS) names and the icons can be any text you want to display. However
# most of these are character codes for font awesome: # most of these are character codes for font awesome:
# http://fortawesome.github.io/Font-Awesome/icons/ # http://fortawesome.github.io/Font-Awesome/icons/
FA_CHROME = "\uF268" FA_CHROME = "\uf268"
FA_CODE = "\uF121" FA_CODE = "\uf121"
FA_DOWNLOAD = "\uF019" FA_DOWNLOAD = "\uf019"
FA_FILE_PDF_O = "\uF1C1" FA_FILE_PDF_O = "\uf1c1"
FA_FILE_TEXT_O = "\uF0F6" FA_FILE_TEXT_O = "\uf0f6"
FA_FILES_O = "\uF0C5" FA_FILES_O = "\uf0c5"
FA_FIREFOX = "\uF269" FA_FIREFOX = "\uf269"
FA_PICTURE_O = "\uF03E" FA_PICTURE_O = "\uf03e"
FA_SPOTIFY = "\uF1BC" FA_SPOTIFY = "\uf1bc"
FA_TERMINAL = "\uF120" FA_TERMINAL = "\uf120"
FA_TELEGRAM = "\uF3FE" FA_TELEGRAM = "\uf3fe"
FA_CUBE = "\uF1B2" FA_CUBE = "\uf1b2"
FA_PAINT_BRUSH = "\uF1FC" FA_PAINT_BRUSH = "\uf1fc"
FA_BOOK = "\uF02D" FA_BOOK = "\uf02d"
FA_FOLDER = "\uF07C" FA_FOLDER = "\uf07c"
FA_CALENDAR = "\uF133" FA_CALENDAR = "\uf133"
FA_BEZIER_CURVE = "\uF55B" FA_BEZIER_CURVE = "\uf55b"
FA_VECTOR_SQUARE = "\uF5CB" FA_VECTOR_SQUARE = "\uf5cb"
FA_VOLUME_UP = "\uF028" FA_VOLUME_UP = "\uf028"
FA_STEAM = "\uF1B6"
WINDOW_ICONS = { WINDOW_ICONS = {
"Blender": FA_CUBE,
"chromium": FA_CHROME,
"code": FA_CODE,
"code-oss": FA_CODE,
"emacs": FA_CODE,
"evince": FA_FILE_PDF_O,
"feh": FA_PICTURE_O,
"Firefox": FA_FIREFOX, "Firefox": FA_FIREFOX,
"gimp-2.10": FA_PAINT_BRUSH,
"gnome-calendar": FA_CALENDAR,
"Gnome-terminal": FA_TERMINAL, "Gnome-terminal": FA_TERMINAL,
"google-chrome": FA_CHROME,
"inkscape": FA_PAINT_BRUSH,
"jetbrains-pycharm": FA_CODE,
"jetbrains-webstorm": FA_CODE,
"libreoffice": FA_FILE_TEXT_O,
"mupdf": FA_FILE_PDF_O,
"nautilus": FA_FOLDER,
"notion-nativefier-102b2f": FA_BOOK,
"org.gnome.Nautilus": FA_FOLDER,
"pulseeffects": FA_VOLUME_UP,
"slic3r-gui": FA_CUBE,
"slic3r-prusa3d": FA_CUBE,
"spotify": FA_SPOTIFY,
"Steam": FA_STEAM,
"subl": FA_CODE,
"subl3": FA_CODE,
"telegram-desktop": FA_TELEGRAM,
"Thunar": FA_FOLDER,
"thunar": FA_FOLDER,
"transmission-gtk": FA_DOWNLOAD,
"urxvt": FA_TERMINAL,
"xfce4-terminal": FA_TERMINAL,
}
WAYLAND_ICONS = {
"Blender": FA_CUBE,
"chromium": FA_CHROME, "chromium": FA_CHROME,
"code": FA_CODE, "code": FA_CODE,
"code-oss": FA_CODE,
"emacs": FA_CODE, "emacs": FA_CODE,
"evince": FA_FILE_PDF_O, "evince": FA_FILE_PDF_O,
"feh": FA_PICTURE_O, "feh": FA_PICTURE_O,
"firefox": FA_FIREFOX,
"gimp-2.10": FA_PAINT_BRUSH, "gimp-2.10": FA_PAINT_BRUSH,
"gnome-calendar": FA_CALENDAR, "gnome-calendar": FA_CALENDAR,
"Gnome-terminal": FA_TERMINAL,
"google-chrome": FA_CHROME, "google-chrome": FA_CHROME,
"inkscape": FA_PAINT_BRUSH, "inkscape": FA_PAINT_BRUSH,
"jetbrains-pycharm": FA_CODE, "jetbrains-pycharm": FA_CODE,
@ -98,20 +59,15 @@ WAYLAND_ICONS = {
"mupdf": FA_FILE_PDF_O, "mupdf": FA_FILE_PDF_O,
"nautilus": FA_FOLDER, "nautilus": FA_FOLDER,
"notion-nativefier-102b2f": FA_BOOK, "notion-nativefier-102b2f": FA_BOOK,
"org.gnome.Nautilus": FA_FOLDER,
"pulseeffects": FA_VOLUME_UP, "pulseeffects": FA_VOLUME_UP,
"slic3r-gui": FA_CUBE,
"slic3r-prusa3d": FA_CUBE, "slic3r-prusa3d": FA_CUBE,
"spotify": FA_SPOTIFY, "spotify": FA_SPOTIFY,
"Steam": FA_STEAM,
"subl": FA_CODE, "subl": FA_CODE,
"subl3": FA_CODE, "subl3": FA_CODE,
"telegram-desktop": FA_TELEGRAM, "telegram-desktop": FA_TELEGRAM,
"Thunar": FA_FOLDER,
"thunar": FA_FOLDER,
"transmission-gtk": FA_DOWNLOAD, "transmission-gtk": FA_DOWNLOAD,
"thunar": FA_FOLDER,
"urxvt": FA_TERMINAL, "urxvt": FA_TERMINAL,
"xfce4-terminal": FA_TERMINAL,
} }
@ -125,10 +81,9 @@ def xprop(win_id, property):
Requires xorg-xprop to be installed. Requires xorg-xprop to be installed.
""" """
try: try:
prop = proc.check_output( prop = proc.check_output(['xprop', '-id', str(win_id), property],
["xprop", "-id", str(win_id), property], stderr=proc.DEVNULL stderr=proc.DEVNULL)
) prop = prop.decode('utf-8')
prop = prop.decode("utf-8")
return re.findall('"([^"]+)"', prop) return re.findall('"([^"]+)"', prop)
except proc.CalledProcessError: except proc.CalledProcessError:
print(f"Unable to get property for window '{win_id}'") print(f"Unable to get property for window '{win_id}'")
@ -136,21 +91,13 @@ def xprop(win_id, property):
def icon_for_window(window): def icon_for_window(window):
if window.app_id: classes = xprop(window.window, 'WM_CLASS')
# Wayland
if window.app_id in WAYLAND_ICONS:
return WAYLAND_ICONS[window.app_id]
else:
print(f"No icon available for app ID '{window.app_id}'")
return "*"
classes = xprop(window.window, "WM_CLASS")
if classes: if classes:
for cls in classes: for cls in classes:
if cls in WINDOW_ICONS: if cls in WINDOW_ICONS:
return WINDOW_ICONS[cls] return WINDOW_ICONS[cls]
print("No icon available for window with classes: %s" % str(classes)) print('No icon available for window with classes: %s' % str(classes))
return "*" return '*'
def rename(): def rename():
@ -168,16 +115,17 @@ def rename():
def on_change(i3, e): def on_change(i3, e):
"""Call rename() on relevant window events.""" """Call rename() on relevant window events."""
print(f"{e.change}") print(f"{e.change}")
if e.change in ["new", "close", "move"]: if e.change in ['new', 'close', 'move']:
rename() rename()
def main(): def main():
rename() rename()
i3.on("window", on_change) i3.on('window', on_change)
i3.main() i3.main()
if __name__ == "__main__": if __name__ == "__main__":
main() main()