From da3ffa44ddcb4702761957d74898c6c3b802939f Mon Sep 17 00:00:00 2001 From: Sam Mason Date: Wed, 18 Oct 2023 12:30:19 +0100 Subject: [PATCH] fix up Ruff issues --- autoname-workspaces.py | 3 ++- inactive-windows-transparency.py | 6 ++++-- switch-top-level.py | 11 ++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/autoname-workspaces.py b/autoname-workspaces.py index 3ec3992..1815546 100755 --- a/autoname-workspaces.py +++ b/autoname-workspaces.py @@ -8,12 +8,13 @@ # Based on https://github.com/maximbaz/dotfiles/blob/master/bin/i3-autoname-workspaces import argparse -import i3ipc import logging import re import signal import sys +import i3ipc + WINDOW_ICONS = { "firefox": "", } diff --git a/inactive-windows-transparency.py b/inactive-windows-transparency.py index b81134d..bf98917 100755 --- a/inactive-windows-transparency.py +++ b/inactive-windows-transparency.py @@ -6,18 +6,20 @@ # transparency strength in range of 0…1 or use the command line argument -o. import argparse -import i3ipc import signal import sys from functools import partial +import i3ipc + + def on_window_focus(inactive_opacity, ipc, event): global prev_focused global prev_workspace focused_workspace = ipc.get_tree().find_focused() - if focused_workspace == None: + if focused_workspace is None: return focused = event.container diff --git a/switch-top-level.py b/switch-top-level.py index a00700d..94aa0e6 100755 --- a/switch-top-level.py +++ b/switch-top-level.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import i3ipc + # # This script requires i3ipc-python package (install it from a system package manager # or pip). @@ -35,7 +36,7 @@ def __init__(self): self.prev = None # previously focused container id self.i3 = i3ipc.Connection() - self.i3.on('window::focus', self.on_window_focus) + self.i3.on("window::focus", self.on_window_focus) self.i3.on(i3ipc.Event.BINDING, self.on_binding) self.update_top_level() @@ -85,14 +86,14 @@ def on_top(self, _i3, _event, diff: int): top_idx = (top_idx + diff + len(ws)) % len(ws) next_top = ws[top_idx] next_window = self.top_to_selected.get(next_top) - self.i3.command('[con_id=%s] focus' % next_window) + self.i3.command("[con_id=%s] focus" % next_window) def on_binding(self, i3, event): - if event.binding.command.startswith('nop top_next'): + if event.binding.command.startswith("nop top_next"): self.on_top(i3, event, 1) - elif event.binding.command.startswith('nop top_prev'): + elif event.binding.command.startswith("nop top_prev"): self.on_top(i3, event, -1) -if __name__ == '__main__': +if __name__ == "__main__": TopLevelSwitcher()