diff --git a/nix/configurations/vanadium/home/xmobar/xmobar.hs b/nix/configurations/vanadium/home/xmobar/xmobar.hs index 42755533..99778b5b 100644 --- a/nix/configurations/vanadium/home/xmobar/xmobar.hs +++ b/nix/configurations/vanadium/home/xmobar/xmobar.hs @@ -2,48 +2,6 @@ import Xmobar import Data.Function ((&)) import Data.List (intercalate) -import Data.Map qualified as M -import System.Process - -parseXRDB :: String -> M.Map String String -parseXRDB = M.fromList . parseXRDBLines . lines - -parseXRDBLines :: [String] -> [(String, String)] -parseXRDBLines = map parseXRDBLine - -parseXRDBLine :: String -> (String, String) -parseXRDBLine s = case break (== ':') s of - (k, ':' : v) -> (k, dropWhile (== '\t') v) - _ -> error $ "Failed to parse " <> s - --- | Hack to adapt the bar height, fontsize, etc, with the chosen dpi in XRDB -withDynamicDPI :: Config -> IO Config -withDynamicDPI cfg = do - xrdbConfig <- parseXRDB <$> readCreateProcess (shell "xrdb -query") mempty - case xrdbConfig M.!? "Xft.dpi" of - Nothing -> pure cfg - Just dpiStr -> - let - dpi = read dpiStr - - -- In case of low DPI: - -- * reduce height - -- * increase font size - isLowDPI = dpi < 120 - - updatePosition (BottomH x) = BottomH $ if isLowDPI then 15 else x - updatePosition x = x - - updateFontSize x = k <> " " <> v' - where - (k, ' ' : v) = break (== ' ') x - v' = if isLowDPI then "9" else v - in - pure $ cfg - { dpi = dpi - , position = updatePosition (position cfg) - , font = updateFontSize (font cfg) - } config :: Config config = @@ -141,4 +99,4 @@ minute :: Int -> Int minute = (* 60) . second main :: IO () -main = withDynamicDPI config >>= xmobar +main = xmobar config diff --git a/nix/configurations/vanadium/nixos/display.nix b/nix/configurations/vanadium/nixos/display.nix index 6737924a..88eed034 100644 --- a/nix/configurations/vanadium/nixos/display.nix +++ b/nix/configurations/vanadium/nixos/display.nix @@ -38,8 +38,7 @@ fingerprints = { built-in = singleton "eDP-1" "00ffffffffffff0009e5ca0b000000002f200104a51c137803de50a3544c99260f505400000001010101010101010101010101010101115cd01881e02d50302036001dbe1000001aa749d01881e02d50302036001dbe1000001a000000fe00424f452043510a202020202020000000fe004e4531333546424d2d4e34310a0073"; - amethyst = device: singleton device "00ffffffffffff0006b35b27010101012c210103803c22782a29d5ad4f44a7240f5054bfef00714f81809500d1c0d1e8d1fc01010101565e00a0a0a029503020350055502100001a000000fd0030901edf3c000a202020202020000000fc005647323741514c33410a202020000000ff0052414c4d51533139373533370a0111020347f14a90030204014061603f1f230907078301000067030c002000384468d85dc401788003026d1a000002013090f00069096909e305ff01e6060701696900e2006ae20fc0eae70070a0a067500820980455502100001a6fc200a0a0a055503020350055502100001a5aa000a0a0a046503020350055502100001a0000bc"; - orchid = device: singleton device "00ffffffffffff0004699a24642900002416010380341d782a2ac5a4564f9e280f5054b7ef00714f814081809500b300d1c081c08100023a801871382d40582c450009252100001e000000ff0043394c4d54463031303539360a000000fd00324b185311000a202020202020000000fc00415355532056533234370a20200173020322714f0102031112130414050e0f1d1e1f10230917078301000065030c0010008c0ad08a20e02d10103e9600092521000018011d007251d01e206e28550009252100001e011d00bc52d01e20b828554009252100001e8c0ad090204031200c4055000925210000180000000000000000000000000000000000000000005d"; + asus-monitor = device: singleton device "00ffffffffffff0006b35b27010101012c210103803c22782a29d5ad4f44a7240f5054bfef00714f81809500d1c0d1e8d1fc01010101565e00a0a0a029503020350055502100001a000000fd0030901edf3c000a202020202020000000fc005647323741514c33410a202020000000ff0052414c4d51533139373533370a0111020347f14a90030204014061603f1f230907078301000067030c002000384468d85dc401788003026d1a000002013090f00069096909e305ff01e6060701696900e2006ae20fc0eae70070a0a067500820980455502100001a6fc200a0a0a055503020350055502100001a5aa000a0a0a046503020350055502100001a0000bc"; }; devices = rec { @@ -96,24 +95,16 @@ primary = true; }; }; - enableAmethyst = name: { + enableDevice = name: { ${name} = { enable = true; primary = true; crtc = 1; mode = "2560x1440"; + position = "2256x0"; # on the right of built-in rate = "59.95"; }; }; - enableOrchid = name: { - ${name} = { - enable = true; - primary = true; - crtc = 1; - mode = "1920x1080"; - rate = "60.00"; - }; - }; }; frameworkBuiltin = { @@ -125,14 +116,14 @@ hooks.postswitch = switches.setDPI {dpi = 150;}; }; - mkAmethyst = name: { + mkAsusProfile = name: { fingerprint = lib.mkMerge [ fingerprints.built-in - (fingerprints.amethyst name) + (fingerprints.asus-monitor name) ]; config = lib.mkMerge [ configs.allOff - (configs.enableAmethyst name) + (configs.enableDevice name) ]; hooks.postswitch = lib.mkMerge [ (switches.setDPI {dpi = 110;}) @@ -150,38 +141,10 @@ }) ]; }; - - mkOrchid = name: { - fingerprint = lib.mkMerge [ - fingerprints.built-in - (fingerprints.orchid name) - ]; - config = lib.mkMerge [ - configs.allOff - (configs.enableOrchid name) - ]; - hooks.postswitch = lib.mkMerge [ - (switches.setDPI {dpi = 100;}) - (switches.setSoftwareBrightness { - device = name; - brightness = 1; - }) - # # seems like this display doesn't support DDC - # (switches.setDDCBrightness { - # modelName = "VG27AQL3A"; - # brightness = 0; - # }) - # (switches.setDDCContrast { - # modelName = "VG27AQL3A"; - # contrast = 0.5; - # }) - ]; - }; in lib.mkMerge [ {default = frameworkBuiltin;} - (lib.genAttrs' devices.extern (name: lib.nameValuePair "amethyst-${name}" (mkAmethyst name))) - (lib.genAttrs' devices.extern (name: lib.nameValuePair "orchid-${name}" (mkOrchid name))) + (lib.genAttrs' devices.extern (name: lib.nameValuePair "asus-${name}" (mkAsusProfile name))) ]; }; }