2016-03-31 02:06:44 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
from subprocess import call
|
|
|
|
import i3ipc
|
|
|
|
|
|
|
|
i3 = i3ipc.Connection()
|
|
|
|
|
|
|
|
parser = ArgumentParser(prog='disable-standby-fs',
|
|
|
|
description='''
|
|
|
|
Disable standby (dpms) and screensaver when a window becomes fullscreen
|
|
|
|
or exits fullscreen-mode. Requires `xorg-xset`.
|
|
|
|
''')
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
def on_fullscreen_mode(i3, e):
|
|
|
|
if e.container.props.fullscreen_mode:
|
2017-10-03 10:35:02 +00:00
|
|
|
call(['xautolock', '-disable'])
|
|
|
|
print("disabling autolock")
|
2016-03-31 02:06:44 +00:00
|
|
|
else:
|
2017-10-03 10:35:02 +00:00
|
|
|
call(['xautolock', '-enable'])
|
|
|
|
print("enabling autolock")
|
2016-03-31 02:06:44 +00:00
|
|
|
|
|
|
|
def on_window_close(i3, e):
|
|
|
|
if e.container.props.fullscreen_mode:
|
2017-10-03 10:35:02 +00:00
|
|
|
call(['xautolock', '-enable'])
|
|
|
|
print("enabling autolock")
|
2016-03-31 02:06:44 +00:00
|
|
|
|
|
|
|
i3.on('window::fullscreen_mode', on_fullscreen_mode)
|
|
|
|
i3.on('window::close', on_window_close)
|
|
|
|
|
|
|
|
i3.main()
|