From c580972273d87f1aeda6d2d191ff4006fa128d06 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Tue, 11 Jan 2022 02:00:37 -0300 Subject: [PATCH] major waybar refactor fix notmuch issue add which-key-nvim --- overlays/default.nix | 5 + pkgs/default.nix | 1 - pkgs/unread-mail/default.nix | 31 ----- users/misterio/features/cli/nvim/default.nix | 5 +- .../misterio/features/desktop-sway/waybar.nix | 115 +++++++++++++----- 5 files changed, 94 insertions(+), 63 deletions(-) delete mode 100644 pkgs/unread-mail/default.nix diff --git a/overlays/default.nix b/overlays/default.nix index 90548026..3ec28cf3 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -37,6 +37,11 @@ final: prev: }; }; + # https://github.com/NixOS/nixpkgs/issues/154297 + notmuch = prev.notmuch.overrideAttrs (oldAttrs: rec { + doCheck = false; + }); + todoman = prev.todoman.overrideAttrs (oldAttrs: rec { patches = (oldAttrs.patches or [ ]) ++ [ ./todoman-kwargs-crash.patch ]; }); diff --git a/pkgs/default.nix b/pkgs/default.nix index cd39accc..3c5fb363 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,7 +5,6 @@ rgbdaemon = pkgs.callPackage ./rgbdaemon { }; sistemer-bot = pkgs.callPackage ./sistemer-bot { }; - unread-mail = pkgs.callPackage ./unread-mail { }; preferredplayer = pkgs.callPackage ./preferredplayer { }; zenity-askpass = pkgs.callPackage ./zenity-askpass { }; diff --git a/pkgs/unread-mail/default.nix b/pkgs/unread-mail/default.nix deleted file mode 100644 index 25fc785a..00000000 --- a/pkgs/unread-mail/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, stdenv, writeShellScriptBin, jq, xmlstarlet }: - -with lib; - -stdenv.mkDerivation { - name = "unread-mail"; - version = "1.0"; - src = writeShellScriptBin "unread-mail" '' - count=$(find ~/Mail/*/INBOX/new -type f | wc -l) - if [ "$count" == "0" ]; then - subjects="No new mail" - icon="read" - else - subjects=$(grep -h "Subject: " -r ~/Mail/*/INBOX/new | cut -d ':' -f2- | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | ${xmlstarlet}/bin/xml esc | sed -e 's/^/\-/') - icon="unread" - fi - ${jq}/bin/jq -cn --arg tooltip "$subjects" --arg text "$count" --arg alt "$icon" '{tooltip: $tooltip, text: $text, alt: $alt}' - ''; - dontBuild = true; - dontConfigure = true; - installPhase = - "install -Dm 0755 $src/bin/unread-mail $out/bin/unread-mail"; - - meta = { - description = "A script for getting unread email"; - license = licenses.mit; - platforms = platforms.all; - maintainers = with maintainers; [ misterio77 ]; - }; -} - diff --git a/users/misterio/features/cli/nvim/default.nix b/users/misterio/features/cli/nvim/default.nix index 33ca21b9..6e97770b 100644 --- a/users/misterio/features/cli/nvim/default.nix +++ b/users/misterio/features/cli/nvim/default.nix @@ -51,7 +51,6 @@ with inputs.nix-colors.lib { inherit pkgs; }; ''; plugins = with pkgs.vimPlugins; [ editorconfig-vim - registers-nvim vim-fugitive vim-illuminate vim-matchup @@ -69,6 +68,10 @@ with inputs.nix-colors.lib { inherit pkgs; }; plugin = nvim-autopairs; config = "lua require('nvim-autopairs').setup{}"; } + { + plugin = which-key-nvim; + config = "lua require('which-key').setup{}"; + } { plugin = vimThemeFromScheme { scheme = config.colorscheme; }; config = "colorscheme nix-${config.colorscheme.slug}"; diff --git a/users/misterio/features/desktop-sway/waybar.nix b/users/misterio/features/desktop-sway/waybar.nix index d5d955bd..43e0076d 100644 --- a/users/misterio/features/desktop-sway/waybar.nix +++ b/users/misterio/features/desktop-sway/waybar.nix @@ -1,6 +1,21 @@ -{ config, features, lib, pkgs, ... }: +{ config, features, lib, pkgs, hostname, ... }: -let keyring = import ../trusted/keyring.nix { inherit pkgs; }; +let + keyring = import ../trusted/keyring.nix { inherit pkgs; }; + xml = "${pkgs.xmlstarlet}/bin/xml"; + jq = "${pkgs.jq}/bin/jq"; + jqOutput = { pre ? "", text ? "", tooltip ? "", alt ? "", class ? "", percentage ? "" }: '' + ${pre} + ${jq} -cn \ + --arg text "${text}" \ + --arg tooltip "${tooltip}" \ + --arg alt "${alt}" \ + --arg class "${class}" \ + --arg percentage "${percentage}" \ + '{text:$text,tooltip:$tooltip,alt:$alt,class:$class,percentage:$percentage}' + ''; + ping = host: ''$(ping -qc1 ${host} 2>&1 | awk -F/ '/^rtt/ { printf "%.1fms", $5; ok = 1 } END { if (!ok) print "Disconnected" }')''; + pingTargets = builtins.filter (h: h != "${hostname}.local") [ "misterio.me" "merope.local" "atlas.local" "pleione.local" "maia.local" ]; in { programs.waybar = { @@ -76,70 +91,110 @@ in }; }; network = { - interval = 20; + interval = 5; format-wifi = " {essid}"; - format-ethernet = " {ipaddr}/{cidr}"; + format-ethernet = " Connected"; format-disconnected = ""; + tooltip-format = '' + {ifname} + {ipaddr}/{cidr} + Up: {bandwidthUpBits} + Down: {bandwidthDownBits}''; }; "custom/home" = { interval = 5; - exec = '' - ping -qc1 merope.local 2>&1 | awk -F/ '/^rtt/ { printf "%.1fms", $5; ok = 1 } END { if (!ok) print "Disconnected" }' - ''; + return-type = "json"; + exec = jqOutput { + text = ping "merope.local"; + tooltip = builtins.concatStringsSep "\n" + (lib.forEach pingTargets (h: ''${h}: ${ping h}'')); + }; format = " {}"; }; "custom/menu" = { - format = ""; + return-type = "json"; + exec = jqOutput { + text = ""; + tooltip = ''$(cat /etc/os-release | grep PRETTY_NAME | cut -d '"' -f2)''; + }; on-click = "${pkgs.wofi}/bin/wofi -S drun"; }; "custom/unread-mail" = { - exec = "${pkgs.unread-mail}/bin/unread-mail"; + interval = 5; return-type = "json"; + exec = jqOutput { + pre = '' + count=$(find ~/Mail/*/INBOX/new -type f | wc -l) + if [ "$count" == "0" ]; then + subjects="No new mail" + status="read" + else + subjects=$(\ + grep -h "Subject: " -r ~/Mail/*/INBOX/new | cut -d ':' -f2- | \ + perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | ${xml} esc | sed -e 's/^/\-/'\ + ) + status="unread" + fi + ''; + text = "$count"; + tooltip = "$subjects"; + alt = "$status"; + }; format = "{icon} ({})"; format-icons = { "read" = ""; "unread" = ""; }; - interval = 1; }; "custom/gpg-agent" = lib.mkIf (builtins.elem "trusted" features) { - # Check if GPG Agent is caching passphrase - exec = '' - ${keyring.isUnlocked} && echo -e "\nGPG is unlocked" || echo -e "\nGPG is locked" - ''; - interval = 5; - }; - "custom/ethminer" = { - exec-if = "systemctl --user is-active ethminer"; - exec = - "journalctl --user -n 10 -u ethminer | grep '-e \\ m\\ .*' | cut -d ' ' -f12-13"; - interval = 2; - format = "{}"; + interval = 3; + return-type = "json"; + exec = jqOutput { + pre = ''status=$(${keyring.isUnlocked} && echo "unlocked" || echo "locked")''; + alt = "$status"; + tooltip = "GPG is $status"; + }; + format = "{icon}"; + format-icons = { + "locked" = ""; + "unlocked" = ""; + }; }; "custom/gamemode" = { exec-if = "${pkgs.gamemode}/bin/gamemoded --status | grep 'is active' -q"; - interval = 2; + interval = 3; exec = '' echo '{"tooltip": "Gamemode is active"}' ''; format = ""; }; "custom/theme" = { - format = " ${config.colorscheme.slug}"; + interval = "10"; + return-type = "json"; + exec = jqOutput { + text = "${config.colorscheme.slug}"; + tooltip = "${config.colorscheme.name} theme"; + }; + format = " {}"; }; "custom/gpu" = { - exec = "cat /sys/class/drm/card0/device/gpu_busy_percent"; interval = 3; + return-type = "json"; + exec = jqOutput { + text = "$(cat /sys/class/drm/card0/device/gpu_busy_percent)"; + tooltip = "GPU Usage"; + }; format = "力 {}%"; }; "custom/preferredplayer" = { - exec = '' - player="$(${pkgs.preferredplayer}/bin/preferredplayer || echo No player set)"; \ - echo "{\"alt\": \"$player\", \"tooltip\": \"$player \"}" - ''; - return-type = "json"; interval = 2; + return-type = "json"; + exec = jqOutput { + pre = ''player="$(${pkgs.preferredplayer}/bin/preferredplayer || echo No player set)"''; + alt = "$player"; + tooltip = "$player"; + }; format = "{icon}"; format-icons = { "Celluloid" = "";