From 76cf66f3a3948559692475267eac49d4f2e1a580 Mon Sep 17 00:00:00 2001 From: Paul-Henri Froidmont Date: Tue, 21 Mar 2023 23:02:30 +0100 Subject: [PATCH] Use polybar instead of xmobar --- hosts/nixos-desktop/default.nix | 1 + modules/desktop/default.nix | 19 +- modules/desktop/files/scripts/mpd_status.sh | 20 -- modules/desktop/files/xmobarrc | 73 ------- modules/desktop/files/xmonad.hs | 21 +- modules/desktop/xmonad.nix | 230 +++++++++++++++++++- modules/editor/emacs/doom.d/config.el | 4 +- modules/hardware/audio.nix | 4 + 8 files changed, 243 insertions(+), 129 deletions(-) delete mode 100755 modules/desktop/files/scripts/mpd_status.sh delete mode 100644 modules/desktop/files/xmobarrc diff --git a/hosts/nixos-desktop/default.nix b/hosts/nixos-desktop/default.nix index fba23cf..cd3d534 100644 --- a/hosts/nixos-desktop/default.nix +++ b/hosts/nixos-desktop/default.nix @@ -2,6 +2,7 @@ imports = [ ./hardware-configuration.nix ]; modules = { + hardware = { audio.enable = true; }; desktop = { xmonad.enable = true; alacritty.enable = true; diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index ba61170..b7a2a78 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -9,9 +9,9 @@ in { fonts = { fonts = with pkgs.unstable; [ corefonts # Microsoft free fonts - meslo-lgs-nf + (nerdfonts.override { fonts = [ "Meslo" ]; }) ]; - fontconfig.defaultFonts = { monospace = [ "MesloLGS NF" ]; }; + fontconfig.defaultFonts = { monospace = [ "MesloLGS Nerd Font Mono" ]; }; }; programs.adb.enable = true; @@ -43,20 +43,7 @@ in { enableSshSupport = false; pinentryFlavor = "gtk2"; }; - stalonetray = { - enable = true; - config = { - geometry = "1x1-5+0"; - background = "#000000"; - transparent = true; - grow_gravity = "E"; - icon_gravity = "E"; - icon_size = "24"; - kludges = "force_icons_size"; - }; - }; unclutter.enable = true; - pasystray.enable = true; screen-locker = { enable = false; inactiveInterval = 5; @@ -128,7 +115,6 @@ in { file = { ".wallpaper.png".source = ./files/wallpaper.png; - ".xmonad/xmobarrc".source = ./files/xmobarrc; ".config/ncmpcpp" = { source = ./files/ncmpcpp; recursive = true; @@ -163,7 +149,6 @@ in { (ncmpcpp.override { visualizerSupport = true; }) mpc_cli - pulsemixer # Ranger preview utils w3m diff --git a/modules/desktop/files/scripts/mpd_status.sh b/modules/desktop/files/scripts/mpd_status.sh deleted file mode 100755 index 805d6f4..0000000 --- a/modules/desktop/files/scripts/mpd_status.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /usr/bin/env bash -# -# Writes the title and artist of the song currently being played by MPD or MOC to STDOUT, formatted for xmobar -# If MPD is playing a song or is paused, its information will be written. If not, MOC will be checked similarly. -# If neither are playing a song or are paused, nothing will be written. -# Note: if MPD isn't playing some errors will be written to STDERR; don't worry - xmobar only looks at STDOUT - -TCOL="cyan" # The colour to be used to draw the song title when playing -ACOL="lightblue" # The colour to be used to draw the song artist when playing -PCOL="#928374" # The colour to be used to draw both the song title and artist when paused - -MPDSTATE=$(mpc | sed -e '2 !d' -e 's/^.*\[//' -e 's/\].*$//') - -if [ $MPDSTATE == "playing" ]; then - # MPD is playing - echo "$(mpc current | sed "s/ - /\<\/fc\> - \/")" -elif [ $MPDSTATE == "paused" ]; then - # MPD is paused - echo "$(mpc current)" -fi diff --git a/modules/desktop/files/xmobarrc b/modules/desktop/files/xmobarrc deleted file mode 100644 index db0787b..0000000 --- a/modules/desktop/files/xmobarrc +++ /dev/null @@ -1,73 +0,0 @@ -Config { - font = "monospace Bold 12" - additionalFonts= ["monospace Normal 14"] - , bgColor = "#282828" - , fgColor = "#ebdbb2" - , position = TopSize L 94 24 - , alpha = 150 - , commands = [ Run Cpu [ "-t", "\xe266 %" - , "-L", "3","-H","50" - , "-l", "#ebdbb2" - , "-n", "#ebdbb2" - , "-h", "#fb4934" - , "-p", "2" - , "-c", "0" - ] 10 - , Run Memory [ "-t", "\xf85a %" - , "-H", "80" - , "-L", "10" - , "-l" ,"#ebdbb2" - , "-n", "#ebdbb2" - , "-h", "#fb4934" - , "-p", "2" - , "-c", "0" - ] 10 - , Run Date "%a %b %_d %k:%M" - "date" - 10 - , Run DynNetwork [ "-t", "\xf6d9 \xfa51 " - , "-H", "200" - , "-L", "10" - , "-h", "#ebdbb2" - , "-l", "#ebdbb2" - , "-n", "#ebdbb2" - , "-S", "True" - , "-p", "3" - , "-c", "0" - ] 10 - , Run CoreTemp [ "-t", "\xf2c8 °" - , "-L", "30" - , "-H", "75" - , "-l", "lightblue" - , "-n", "#ebdbb2" - , "-h", "#aa4450" - , "-p", "2" - , "-c", "0" - ] 50 - , Run Com ".xmonad/scripts/mpd_status.sh" - [] - "mpdstatus" - 10 - --, Run Com "network-check.sh" [] "netcheck" 5 - , Run BatteryP [ "BAT0" ] - [ "--template" , "\xf240 " - , "--Low" , "10" -- units: % - , "--High" , "80" -- units: % - , "--low" , "#fb4934" -- #ff5555 - , "--normal" , "#ebdbb2" - , "--high" , "#98be65" - - , "--" -- battery specific options - -- discharging status - , "-o" , "% ()" - -- AC "on" status - , "-O" , "% (Charging)" -- 50fa7b - -- charged status - , "-i" , "Charged" - ] 50 - , Run StdinReader - ] - , sepChar = "%" - , alignSep = "}{" - , template = "%StdinReader% }{%dynnetwork% %mpdstatus% %cpu% %coretemp% %memory% %battery% %date% " -- #69DFFA - } diff --git a/modules/desktop/files/xmonad.hs b/modules/desktop/files/xmonad.hs index 679b859..650433f 100644 --- a/modules/desktop/files/xmonad.hs +++ b/modules/desktop/files/xmonad.hs @@ -54,10 +54,9 @@ myFocusFollowsMouse :: Bool myFocusFollowsMouse = True main = do - xmproc <- spawnPipe "xmobar .xmonad/xmobarrc" - xmonad $ ewmh . docks $ myConfig xmproc + xmonad $ ewmh . docks $ myConfig -myConfig xmproc = azertyConfig { +myConfig = azertyConfig { terminal = myTerminal, focusFollowsMouse = True, borderWidth = 1, @@ -68,19 +67,11 @@ myConfig xmproc = azertyConfig { layoutHook = myLayout, manageHook = manageDocks <+> (isFullscreen --> doFullFloat) <+> manageHook def, --handleEventHook = myEventHook <+> handleEventHook def, - logHook = (myLogHook xmproc) <+> logHook def, + logHook = logHook def, --keys = \c -> mkKeymap c myAdditionalKeys, - startupHook = myStartupHook xmproc + startupHook = myStartupHook } `removeKeysP` myRemoveKeys `additionalKeysP` myAdditionalKeys -myLogHook xmproc = dynamicLogWithPP xmobarPP { - ppOutput = hPutStrLn xmproc, - ppCurrent = xmobarColor "#83a598" "" . wrap "[" "]", -- #9BC1B2 #69DFFA - ppTitle = xmobarColor "#d3869b" "" . shorten 100, -- #9BC1B2 #69DFFA - ppSort = fmap (. filterOutWs [scratchpadWorkspaceTag]) getSortByTag - --ppLayout = xmobarColor "#fabd2f" "" . myIcons -} >> updatePointer (0.75, 0.75) (0.75, 0.75) - myRemoveKeys = [ ] @@ -134,7 +125,7 @@ myLayout = smartSpacing 5 $ avoidStruts $ layoutHook def -myStartupHook xmproc = do +myStartupHook = do setWMName "LG3D" spawn "feh --no-fehbg --bg-fill ~/.wallpaper.png" - return () >> checkKeymap (myConfig xmproc) myAdditionalKeys + return () >> checkKeymap myConfig myAdditionalKeys diff --git a/modules/desktop/xmonad.nix b/modules/desktop/xmonad.nix index e2fc234..2a4dc62 100644 --- a/modules/desktop/xmonad.nix +++ b/modules/desktop/xmonad.nix @@ -17,7 +17,7 @@ in { displayManager.lightdm = { enable = true; background = ./files/wallpaper.png; - greeters.mini.enable = true; + #greeters.mini.enable = true; }; }; @@ -29,8 +29,234 @@ in { config = ./files/xmonad.hs; }; }; + + services.polybar = { + enable = true; + + package = pkgs.polybar.override { + pulseSupport = true; + mpdSupport = true; + }; + + script = '' + export MONITOR=$(polybar -m|tail -1|sed -e 's/:.*$//g') + + polybar main & + ''; + + settings = { + "colors" = { + bg = "#282828"; + bg-alt = "#3c3836"; + bg-darker = "#1d2021"; + fg = "#fbf1c7"; + fg-alt = "#928374"; + + blue = "#83a598"; + cyan = "#8ec07c"; + green = "#b8bb26"; + orange = "#fe8019"; + purple = "#d3869b"; + red = "#fb4934"; + yellow = "#fabd2f"; + + bg-blue = "#458588"; + bg-cyan = "#689d6a"; + bg-green = "#98971a"; + bg-orange = "#d65d0e"; + bg-purple = "#b16268"; + bg-red = "#cc241d"; + bg-yellow = "#d79921"; + + black = "#000"; + white = "#FFF"; + + trans = "#00000000"; + semi-trans = "#ee282828"; + semi-trans-black = "#aa000000"; + accent = "#83a598"; + }; + "global/wm" = { + margin-top = 0; + margin-bottom = 34; + }; + "bar/main" = { + monitor = "\${env:MONITOR}"; + background = "\${colors.bg}"; + foreground = "\${colors.fg}"; + enable-ipc = true; + + width = "100%"; + height = "34"; + offset-x = 0; + offset-y = 0; + bottom = true; + + padding-left = 2; + padding-right = 2; + + font-0 = "MesloLGS Nerd Font Mono:pixelsize=12;2"; + font-1 = "MesloLGS Nerd Font Mono:pixelsize=20;5"; + + modules-left = "pulseaudio pad cpu memory pad fs pad xwindow"; + modules-center = "ewmh"; + modules-right = "mpd pad battery pad date"; + + tray-position = "right"; + tray-offset-y = 2; + }; + "module/ewmh" = { + type = "internal/xworkspaces"; + pin-workspaces = false; + enable-click = false; + enable-scroll = false; + + label-active = "%name%"; + label-active-background = "\${colors.bg-alt}"; + label-active-foreground = "\${colors.fg}"; + label-active-padding = 1; + + label-occupied = "%name%"; + label-occupied-foreground = "\${colors.accent}"; + label-occupied-padding = 1; + + label-urgent-foreground = "\${colors.red}"; + label-urgent-padding = 1; + + label-empty = "%name%"; + label-empty-foreground = "\${colors.fg-alt}"; + label-empty-padding = 1; + }; + "module/date" = { + type = "internal/date"; + interval = 5; + + label = "%date% %time%"; + date = "%A, %d %h"; + date-alt = "%d/%m/%Y"; + time = "%H:%M"; + time-alt = "%H:%M"; + format-foreground = "\${colors.accent}"; + format-prefix = ""; + format-prefix-font = 2; + format-prefix-padding = 1; + format-prefix-foreground = "\${colors.accent}"; + }; + "module/xwindow" = { + type = "internal/xwindow"; + label = "%title:0:80:...%"; + label-padding-left = 2; + + }; + "module/pad" = { + type = "custom/text"; + content = " "; + }; + "module/fs" = { + type = "internal/fs"; + mount-0 = "/"; + interval = 30; + format-mounted = ""; + format-mounted-prefix = "󰋊 "; + format-mounted-prefix-font = 2; + format-mounted-foreground = "\${colors.accent}"; + + format-unmounted = ""; + label-unmounted = ""; + label-unmounted-foreground = "\${colors.fg-alt}"; + + bar-used-indicator = ""; + bar-used-width = 8; + bar-used-foreground-0 = "\${colors.fg}"; + bar-used-foreground-1 = "\${colors.fg}"; + bar-used-foreground-2 = "\${colors.yellow}"; + bar-used-foreground-3 = "\${colors.red}"; + bar-used-foreground-4 = "\${colors.red}"; + bar-used-fill = "|"; + bar-used-empty = "¦"; + bar-used-empty-foreground = "\${colors.fg-alt}"; + }; + "module/cpu" = { + type = "internal/cpu"; + interval = 2; + format = ""; + format-prefix = " "; + format-prefix-font = 2; + format-foreground = "\${colors.accent}"; + format-padding = 1; + + bar-load-indicator = ""; + bar-load-width = 8; + bar-load-foreground-0 = "\${colors.fg}"; + bar-load-foreground-1 = "\${colors.fg}"; + bar-load-foreground-2 = "\${colors.yellow}"; + bar-load-foreground-3 = "\${colors.red}"; + bar-load-foreground-4 = "\${colors.red}"; + bar-load-fill = "|"; + bar-load-empty = "¦"; + bar-load-empty-foreground = "\${colors.fg-alt}"; + }; + "module/memory" = { + type = "internal/memory"; + interval = 3; + format = ""; + format-prefix = " "; + format-prefix-font = 2; + format-prefix-foreground = "\${colors.accent}"; + format-padding-left = 1; + + bar-used-indicator = ""; + bar-used-width = 8; + bar-used-foreground-0 = "\${colors.fg}"; + bar-used-foreground-1 = "\${colors.fg}"; + bar-used-foreground-2 = "\${colors.yellow}"; + bar-used-foreground-3 = "\${colors.red}"; + bar-used-foreground-4 = "\${colors.red}"; + bar-used-fill = "|"; + bar-used-empty = "¦"; + bar-used-empty-foreground = "\${colors.fg-alt}"; + }; + "module/pulseaudio" = { + type = "internal/pulseaudio"; + + format-volume = " "; + label-volume-foreground = "\${colors.accent}"; + + label-muted = "󰖁"; + label-muted-font = 2; + format-muted-foreground = "\${colors.red}"; + format-muted = ""; + + bar-volume-width = 8; + bar-volume-gradient = false; + bar-volume-indicator = "|"; + bar-volume-indicator-foreground = "#ff"; + bar-volume-fill = "─"; + bar-volume-empty = "─"; + bar-volume-empty-foreground = "\${colors.fg-alt}"; + + ramp-volume-0 = "󰕿"; + ramp-volume-1 = "󰖀"; + ramp-volume-2 = "󰕾"; + ramp-volume-font = 2; + }; + "module/mpd" = { + type = "internal/mpd"; + host = "127.0.0.1"; + port = "6600"; + + label-song = "%artist% - %title%"; + format-playing-prefix = "󰎈 "; + format-playing-prefix-font = 2; + format-playing-foreground = "\${colors.fg}"; + format-paused-prefix = "󰎊 "; + format-paused-prefix-font = 2; + format-paused-foreground = "\${colors.fg-alt}"; + }; + }; + }; + home.packages = with pkgs.unstable; [ - haskellPackages.xmobar i3lock feh diff --git a/modules/editor/emacs/doom.d/config.el b/modules/editor/emacs/doom.d/config.el index 30b31e3..1f35cec 100644 --- a/modules/editor/emacs/doom.d/config.el +++ b/modules/editor/emacs/doom.d/config.el @@ -1,8 +1,8 @@ (setq projectile-project-search-path '("~/Projects/") doom-theme 'doom-gruvbox - doom-font (font-spec :family "MesloLGS NF" :size 16) - doom-big-font (font-spec :family "MesloLGS NF" :size 24) + doom-font (font-spec :family "MesloLGS Nerd Font Mono" :size 16) + doom-big-font (font-spec :family "MesloLGS Nerd Font Mono" :size 24) treemacs-git-mode 'extended) ;; Enable nice rendering of diagnostics like compile errors. diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix index 5158e4d..02e7d12 100644 --- a/modules/hardware/audio.nix +++ b/modules/hardware/audio.nix @@ -10,5 +10,9 @@ in { sound.enable = true; hardware.pulseaudio.enable = true; hardware.pulseaudio.support32Bit = true; + + home-manager.users.${config.user.name} = { + home.packages = with pkgs.unstable; [ pulsemixer ]; + }; }; }