Skip to content

Commit a538e5c

Browse files
author
Tony Crisci
committed
format examples
1 parent 8947b9f commit a538e5c

10 files changed

+18
-19
lines changed

examples/focus-last.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from argparse import ArgumentParser
99
import i3ipc
1010

11-
SOCKET_DIR = '{}/i3_focus_last.{}{}'.format(
12-
tempfile.gettempdir(), os.geteuid(), os.getenv("DISPLAY"))
11+
SOCKET_DIR = '{}/i3_focus_last.{}{}'.format(tempfile.gettempdir(), os.geteuid(),
12+
os.getenv("DISPLAY"))
1313
SOCKET_FILE = '{}/socket'.format(SOCKET_DIR)
1414
MAX_WIN_HISTORY = 15
1515

examples/i3-cycle-focus.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
def on_shutdown(i3_conn, e):
2121
os._exit(0)
2222

23+
2324
class FocusWatcher:
2425
def __init__(self):
2526
self.i3 = i3ipc.Connection()

examples/i3-focus/focus-app.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import i3ipc
77
from tools import App, Lists, Menu, Sockets
88

9-
109
parser = ArgumentParser(prog='i3-app-focus.py',
1110
description='''
1211
i3-app-focus.py is dmenu-based script for creating dynamic app switcher.
@@ -18,7 +17,6 @@
1817
parser.add_argument('--socket-file', default='/tmp/i3-app-focus.socket', help='Socket file path')
1918
(args, menu_args) = parser.parse_known_args()
2019

21-
2220
sockets = Sockets(args.socket_file)
2321
containers_info = sockets.get_containers_history()
2422

examples/i3-focus/focus-current-app-window.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import i3ipc
77
from tools import App, Lists, Menu, Sockets
88

9-
109
parser = ArgumentParser(prog='i3-app-focus.py',
1110
description='''
1211
i3-app-focus.py is dmenu-based script for creating dynamic app switcher.
@@ -18,7 +17,6 @@
1817
parser.add_argument('--socket-file', default='/tmp/i3-app-focus.socket', help='Socket file path')
1918
(args, menu_args) = parser.parse_known_args()
2019

21-
2220
sockets = Sockets(args.socket_file)
2321
containers_info = sockets.get_containers_history()
2422

examples/i3-focus/focus-window.py

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import i3ipc
77
from tools import App, Lists, Menu, Sockets
88

9-
109
parser = ArgumentParser(prog='i3-app-focus.py',
1110
description='''
1211
i3-app-focus.py is dmenu-based script for creating dynamic app switcher.
@@ -18,7 +17,6 @@
1817
parser.add_argument('--socket-file', default='/tmp/i3-app-focus.socket', help='Socket file path')
1918
(args, menu_args) = parser.parse_known_args()
2019

21-
2220
sockets = Sockets(args.socket_file)
2321
containers_info = sockets.get_containers_history()
2422

examples/i3-focus/history-server.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@
88
from argparse import ArgumentParser
99
import i3ipc
1010

11-
1211
MAX_WIN_HISTORY = 15
1312

14-
parser = ArgumentParser(prog='i3-app-focus.py',
15-
description='''''',
16-
epilog='''''')
13+
parser = ArgumentParser(prog='i3-app-focus.py', description='''''', epilog='''''')
1714
parser.add_argument('--socket-file', default='/tmp/i3-app-focus.socket', help='Socket file path')
1815
(args, other) = parser.parse_known_args()
1916

17+
2018
class FocusWatcher:
2119
def __init__(self):
2220
self.i3 = i3ipc.Connection()
@@ -71,7 +69,7 @@ def accept(sock):
7169
"focused": con.focused
7270
})
7371

74-
conn.send(json.dumps(info).encode());
72+
conn.send(json.dumps(info).encode())
7573
conn.close()
7674

7775
selector.register(self.listening_socket, selectors.EVENT_READ, accept)
@@ -81,10 +79,10 @@ def accept(sock):
8179
callback = key.data
8280
callback(key.fileobj)
8381

84-
8582
@staticmethod
8683
def _is_window(con):
87-
return not con.nodes and con.type == "con" and (con.parent and con.parent.type != "dockarea" or True)
84+
return not con.nodes and con.type == "con" and (con.parent and con.parent.type != "dockarea"
85+
or True)
8886

8987

9088
focus_watcher = FocusWatcher()

examples/i3-focus/tools/app.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import i3ipc
33

4+
45
class App:
56
def __init__(self, container_info):
67
self._container_info = container_info
@@ -21,7 +22,8 @@ def _get_title_based_on_class(self):
2122
return self._container_info["window_class"].replace('-', ' ').title()
2223

2324
def _get_title_based_on_title(self):
24-
return re.match(r"^.*?\s*(?P<title>[^-—]+)$", self._container_info["window_title"]).group("title")
25+
return re.match(r"^.*?\s*(?P<title>[^-—]+)$",
26+
self._container_info["window_title"]).group("title")
2527

2628
# App specific functions
2729

examples/i3-focus/tools/lists.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from . import App
22

3+
34
class Lists:
45
@staticmethod
56
def accum_uniq_apps(result, app):
@@ -21,7 +22,8 @@ def find_all_by_focused_app(infos):
2122

2223
focused_app = App(focused_info)
2324

24-
focused_app_windows_by_class = list(filter(lambda i: App(i).get_title() == focused_app.get_title(), infos))
25+
focused_app_windows_by_class = list(
26+
filter(lambda i: App(i).get_title() == focused_app.get_title(), infos))
2527
return focused_app_windows_by_class
2628

2729
@staticmethod

examples/i3-focus/tools/menu.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from subprocess import check_output
33
from . import Lists, App
44

5+
56
class Menu:
67
def __init__(self, i3, menu, menu_args):
78
self._i3 = i3
@@ -20,7 +21,7 @@ def show_menu_app(self, apps):
2021
selected_app = Lists.find_app_by_title(selected_title, apps)
2122
tree = self._i3.get_tree()
2223
con = tree.find_by_id(selected_app.get_con_id())
23-
con.command('focus');
24+
con.command('focus')
2425

2526
def show_menu_container_info(self, containers_info):
2627
titles = self._get_titles_with_app_prefix(containers_info)
@@ -30,7 +31,7 @@ def show_menu_container_info(self, containers_info):
3031
selected_info = infos_by_title[selected_title]
3132
tree = self._i3.get_tree()
3233
con = tree.find_by_id(selected_info["id"])
33-
con.command('focus');
34+
con.command('focus')
3435

3536
def _get_titles_with_app_prefix(self, containers_info):
3637
return list(map(lambda i: App(i).get_title() + ': ' + i["window_title"], containers_info))

examples/i3-focus/tools/sockets.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import socket
22
import json
33

4+
45
class Sockets:
56
def __init__(self, socket_file):
67
self._socket_file = socket_file

0 commit comments

Comments
 (0)