From 74ab3229dfab2ae61e34d4c12c0c56aa25665b8f Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 8 Dec 2021 19:05:33 +0100 Subject: [PATCH] xss-dimmer: avoid font jumping by using a fixed width to format text Also, use the same font as when the screen is locked. --- bin/xss-dimmer | 4 ++-- dotfiles/systemd/xss-dimmer@.service | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/xss-dimmer b/bin/xss-dimmer index 5001e38..127b21a 100755 --- a/bin/xss-dimmer +++ b/bin/xss-dimmer @@ -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( diff --git a/dotfiles/systemd/xss-dimmer@.service b/dotfiles/systemd/xss-dimmer@.service index 39a6cd9..59d2b44 100644 --- a/dotfiles/systemd/xss-dimmer@.service +++ b/dotfiles/systemd/xss-dimmer@.service @@ -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