xss-dimmer: avoid font jumping by using a fixed width to format text

Also, use the same font as when the screen is locked.
This commit is contained in:
Vincent Bernat 2021-12-08 19:05:33 +01:00
parent 237fc329bc
commit 74ab3229df
2 changed files with 2 additions and 3 deletions

View file

@ -71,7 +71,7 @@ def on_draw(widget, event, options, background, start):
options.font, cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD
)
cctx.set_font_size(wheight // 4)
_, _, twidth, theight, _, _ = cctx.text_extents(remaining)
_, _, twidth, theight, _, _ = cctx.text_extents("8"*len(remaining))
text_position = wwidth // 2 - twidth // 2, wheight // 2 + theight // 2
cctx.move_to(*text_position)
cctx.set_source_rgba(1, 1, 1, opacity)
@ -133,7 +133,7 @@ if __name__ == "__main__":
add("--end-opacity", type=float, default=1, help="final opacity")
add("--step", type=float, default=0.1, help="step for changing opacity")
add("--delay", type=float, default=10, help="delay from start to end")
add("--font", default="DejaVu Sans", help="font for countdown")
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(

View file

@ -3,5 +3,4 @@ Description=Screen dimmer
[Service]
ExecStart=%h/.config/i3/bin/xss-dimmer --delay=%i \
--font "Monkey Island 1991" \
--background=%t/i3/current-wallpaper.png