mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-08-29 14:18:22 +02:00
dimmer: handle wide screens split in two
This commit is contained in:
parent
a3c2d4897e
commit
2ff8e9bacd
4 changed files with 45 additions and 10 deletions
|
@ -19,6 +19,7 @@ import threading
|
|||
import time
|
||||
import math
|
||||
import os
|
||||
import warnings
|
||||
from Xlib import display, X
|
||||
from Xlib.error import BadWindow
|
||||
from Xlib.protocol.event import MapNotify
|
||||
|
@ -157,6 +158,7 @@ if __name__ == "__main__":
|
|||
add("--font", default="Iosevka Aile", help="font for countdown")
|
||||
add("--locker", default="xsecurelock", help="quit if window class detected")
|
||||
add("--background", help="use a background instead of black")
|
||||
add("--no-randr", help="disable RandR", action="store_true")
|
||||
add(
|
||||
"--easing-function",
|
||||
default="none",
|
||||
|
@ -166,6 +168,16 @@ if __name__ == "__main__":
|
|||
add("--sound", help="play a sound for each second elapsed while dimmer running")
|
||||
options = parser.parse_args()
|
||||
|
||||
# This is a hack!
|
||||
try:
|
||||
with open(
|
||||
os.path.join(os.environ["XDG_RUNTIME_DIR"], "i3", "outputs.txt")
|
||||
) as f:
|
||||
if int(f.read()) == 1:
|
||||
options.no_randr = True
|
||||
except:
|
||||
pass
|
||||
|
||||
background = None
|
||||
if options.background:
|
||||
try:
|
||||
|
@ -175,16 +187,25 @@ if __name__ == "__main__":
|
|||
|
||||
# Setup dimmer windows on each monitor
|
||||
gdisplay = Gdk.Display.get_default()
|
||||
for i in range(gdisplay.get_n_monitors()):
|
||||
geom = gdisplay.get_monitor(i).get_geometry()
|
||||
geoms = []
|
||||
if options.no_randr:
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
screen = gdisplay.get_screen(0)
|
||||
geoms.append((0, 0, screen.get_width(), screen.get_height()))
|
||||
else:
|
||||
for i in range(gdisplay.get_n_monitors()):
|
||||
geom = gdisplay.get_monitor(i).get_geometry()
|
||||
geoms.append((geom.x, geom.y, geom.width, geom.height))
|
||||
|
||||
for x, y, width, height in geoms:
|
||||
window = Gtk.Window()
|
||||
window.set_app_paintable(True)
|
||||
window.set_type_hint(Gdk.WindowTypeHint.SPLASHSCREEN)
|
||||
window.set_visual(window.get_screen().get_rgba_visual())
|
||||
|
||||
window.set_default_size(geom.width, geom.height)
|
||||
window.move(geom.x, geom.y)
|
||||
window.set_default_size(width, height)
|
||||
window.move(x, y)
|
||||
|
||||
window.connect("draw", on_draw, options, background, now)
|
||||
window.connect("delete-event", Gtk.main_quit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue