Skip to content

Commit 29c6f0d

Browse files
author
Tony Crisci
authored
Merge pull request #135 from laur89/master
i3-cycle-focus: kill on i3 'shutdown' event
2 parents 5d2d02a + 6529f33 commit 29c6f0d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

examples/i3-cycle-focus.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/usr/bin/env python3
2+
#
3+
# provides alt+tab functionality between windows, switching
4+
# between n windows; example i3 conf to use:
5+
# exec_always --no-startup-id i3-cycle-focus.py --history 2
6+
# bindsym $mod1+Tab exec --no-startup-id i3-cycle-focus.py --switch
27

38
import os
49
import socket
@@ -7,15 +12,19 @@
712
from argparse import ArgumentParser
813
import i3ipc
914

10-
SOCKET_FILE = '/tmp/i3-cycle-focus'
15+
SOCKET_FILE = '/tmp/.i3-cycle-focus.sock'
1116
MAX_WIN_HISTORY = 16
1217
UPDATE_DELAY = 2.0
1318

1419

20+
def on_shutdown(i3_conn, e):
21+
os._exit(0)
22+
1523
class FocusWatcher:
1624
def __init__(self):
1725
self.i3 = i3ipc.Connection()
1826
self.i3.on('window::focus', self.on_window_focus)
27+
self.i3.on('shutdown', on_shutdown)
1928
self.listening_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
2029
if os.path.exists(SOCKET_FILE):
2130
os.remove(SOCKET_FILE)

0 commit comments

Comments
 (0)