From 85b4be2d0d4ea2c70883f026d1a5bde6230f626e Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 6 May 2024 22:24:32 +0200 Subject: feat: add `--spacing` --- app/Main.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/Main.hs b/app/Main.hs index 701646f..09f0d50 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -28,15 +28,19 @@ import Ui qualified import UnliftIO.STM data Args = Args - { icons :: Bool + { icons :: Bool, + spacing :: Int } args :: O.ParserInfo Args -args = O.info (Args <$> iconsArg) O.idm +args = O.info (Args <$> iconsArg <*> spacingArg) O.idm iconsArg :: O.Parser Bool iconsArg = O.switch (O.long "icons") +spacingArg :: O.Parser Int +spacingArg = O.option O.auto (O.long "spacing" <> O.value 0) + data Env = Env { dpy :: X.Display, win :: X.Window, @@ -45,7 +49,6 @@ data Env = Env wwidth :: Int, wheight :: Int, wleft :: Int, - wtop :: Int, gc :: X.GC, pixm :: X.Pixmap, fnt :: X.XftFont, @@ -152,8 +155,8 @@ createWindow args = do swidth = fi (X.displayWidth dpy scrn) sheight = fi (X.displayHeight dpy scrn) wwidth = swidth - 16 - wleft = 8 - wtop = 8 + wspac = args.spacing + wleft = wspac fnt <- X.xftFontOpen dpy scr "IosevkaTerm Nerd Font:size=14" wheight <- X.xftfont_height fnt cmap <- X.createColormap dpy root vis X.allocNone @@ -162,7 +165,7 @@ createWindow args = do X.set_border_pixel attr 0 X.set_background_pixel attr 0 X.set_override_redirect attr True - X.createWindow dpy root (fi wleft) (fi wtop) (fi wwidth) (fi wheight) 0 dpth cls vis vmsk attr + X.createWindow dpy root (fi wleft) 0 (fi wwidth) (fi wheight) 0 dpth cls vis vmsk attr atom <- X.internAtom dpy "ATOM" True wmState <- X.internAtom dpy "_NET_WM_STATE" False wmStateSticky <- X.internAtom dpy "_NET_WM_STATE_STICKY" False @@ -179,9 +182,9 @@ createWindow args = do [ fi wmWindowTypeDock ] X.changeProperty32 dpy win wmStrut atom X.propModeReplace $ - [0, 0, fi wheight + 8, 0] + [0, 0, fi (wheight + wspac), 0] X.changeProperty32 dpy win wmStrutPartial atom X.propModeReplace $ - [0, 0, fi wheight + 8, 0, 0, 0, 0, 0, fi wleft, fi wwidth, 0, 0] + [0, 0, fi (wheight + wspac), 0, 0, 0, 0, 0, fi wleft, fi wwidth, 0, 0] pixm <- X.createPixmap dpy win (fi wwidth) (fi wheight) dpth gc <- X.createGC dpy win drw <- X.xftDrawCreate dpy pixm vis cmap -- cgit v1.2.3