Skip to content

Commit 22ae1df

Browse files
author
Pi
committed
stay on the same tab without affecting the pause state
1 parent 89e36ae commit 22ae1df

9 files changed

+28
-10
lines changed

gamepad_a

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Press A
44
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
55
xdotool key --window $BROWSER_WINDOW a
6-
touch "$XDG_RUNTIME_DIR/lasttabmove"
6+
./stay-here-longer
77

gamepad_b

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Press B
44
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
55
xdotool key --window $BROWSER_WINDOW b
6-
touch "$XDG_RUNTIME_DIR/lasttabmove"
6+
./stay-here-longer
77

gamepad_start

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ if not os.path.exists(filename):
77
with open(filename, "w") as f:
88
pass
99

10-
now = int(time.time())
11-
last = int(os.stat(filename).st_mtime)
10+
now = time.time()
11+
last = os.stat(filename).st_mtime
1212

1313
if last > now:
1414
print("unpause")
1515
os.system(os.path.dirname(__file__) + "/tab-right")
1616
else:
1717
print("pause")
18-
os.utime(filename, (0, int(time.time()) + 900))
18+
os.utime(filename, (0, now + 900))

gamepad_x

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Press X
44
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
55
xdotool key --window $BROWSER_WINDOW x
6-
touch "$XDG_RUNTIME_DIR/lasttabmove"
6+
./stay-here-longer
77

gamepad_y

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Press Y
44
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
55
xdotool key --window $BROWSER_WINDOW y
6-
touch "$XDG_RUNTIME_DIR/lasttabmove"
6+
./stay-here-longer
77

reload-page

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# reload the current page
22
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
33
xdotool key --window $BROWSER_WINDOW ctrl+r
4-
touch "$XDG_RUNTIME_DIR/lasttabmove"
4+
./stay-here-longer

scroll-down

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# move left one tab
22
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
33
xdotool key --window $BROWSER_WINDOW Down
4-
touch "$XDG_RUNTIME_DIR/lasttabmove"
4+
./stay-here-longer

scroll-up

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# move left one tab
22
BROWSER_WINDOW=$(xdotool search --class '^chromium-browser$')
33
xdotool key --window $BROWSER_WINDOW Up
4-
touch "$XDG_RUNTIME_DIR/lasttabmove"
4+
./stay-here-longer

stay-here-longer

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import time
4+
5+
filename = os.environ["XDG_RUNTIME_DIR"] + "/lasttabmove"
6+
if not os.path.exists(filename):
7+
with open(filename, "w") as f:
8+
pass
9+
10+
now = time.time()
11+
last = os.stat(filename).st_mtime
12+
13+
if last > now:
14+
print("paused")
15+
os.utime(filename, (0, now + 900))
16+
else:
17+
print("not paused")
18+
os.utime(filename, (0, now))

0 commit comments

Comments
 (0)