mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-21 01:25:42 +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
|
@ -380,10 +380,17 @@ if __name__ == "__main__":
|
|||
"--target",
|
||||
default="background.png",
|
||||
help="write background to FILE",
|
||||
metavar="FILE",
|
||||
)
|
||||
group.add_argument(
|
||||
"--compression", default=0, type=int, help="compression level when saving"
|
||||
)
|
||||
group.add_argument(
|
||||
"--outputs",
|
||||
default=None,
|
||||
help="write number of outputs to FILE",
|
||||
metavar="FILE",
|
||||
)
|
||||
options = parser.parse_args()
|
||||
|
||||
# Logging
|
||||
|
@ -420,6 +427,10 @@ if __name__ == "__main__":
|
|||
)
|
||||
build(background, wallpaper_parts)
|
||||
save(background, options.target, options.compression)
|
||||
|
||||
if options.outputs is not None:
|
||||
with open(options.outputs, "w") as f:
|
||||
f.write(str(len(outputs)))
|
||||
except Exception as e:
|
||||
logger.exception("%s", e)
|
||||
sys.exit(1)
|
||||
|
|
|
@ -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()
|
||||
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)
|
||||
|
|
|
@ -4,10 +4,12 @@ PartOf=graphical-session.target
|
|||
|
||||
[Service]
|
||||
Environment=WALLPAPER_DIRECTORY=%h/.config/i3/wallpapers
|
||||
Environment=WALLPAPER_OUTPUT=%t/i3/current-wallpaper.png
|
||||
Environment=WALLPAPER_TARGET=%t/i3/current-wallpaper.png
|
||||
Environment=WALLPAPER_OUTPUTS=%t/i3/outputs.txt
|
||||
ExecStart=/usr/bin/mkdir -p %t/i3
|
||||
ExecStart=%h/.config/i3/bin/wallpaper --directory $WALLPAPER_DIRECTORY \
|
||||
--target $WALLPAPER_OUTPUT
|
||||
ExecStart=/usr/bin/hsetroot -root -center $WALLPAPER_OUTPUT
|
||||
--target $WALLPAPER_TARGET \
|
||||
--outputs $WALLPAPER_OUTPUTS
|
||||
ExecStart=/usr/bin/hsetroot -root -center $WALLPAPER_TARGET
|
||||
Type=oneshot
|
||||
RemainAfterExit=false
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Description=Screen dimmer
|
||||
|
||||
[Service]
|
||||
ExecStart=%h/.config/i3/bin/xss-dimmer --delay=%i \
|
||||
ExecStart=%h/.config/i3/bin/xss-dimmer \
|
||||
--delay=%i \
|
||||
--background=%t/i3/current-wallpaper.png \
|
||||
--sound=/usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
|
||||
TimeoutSec=1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue