diff --git a/home.nix b/home.nix index 7e7eaa4..9bba19b 100644 --- a/home.nix +++ b/home.nix @@ -19,6 +19,7 @@ ./programs/rofi.nix ./programs/tmux.nix ./programs/vscode.nix + ./programs/xmobar ./programs/xmonad ./programs/zathura.nix ./programs/zsh diff --git a/programs/xmobar/default.nix b/programs/xmobar/default.nix new file mode 100644 index 0000000..d5dc86b --- /dev/null +++ b/programs/xmobar/default.nix @@ -0,0 +1,87 @@ +{ pkgs, colorTheme, ... }: let + inherit (pkgs) lib; +in { + programs.xmobar = let + networkCard = "wlp2s0f0u7u4"; + disks = [ + "/" + "/data" + "/data/disks/data2" + ]; + in { + enable = true; + extraConfig = '' + Config { + font = "xft:Fira Code Retina:pixelsize=15:antialias=true:hinting=true" + , additionalFonts = [ + "xft:Droid Sans Japanese:pixelsize=20:antialias=true:hinting=true", + "xft:Symbola:pixelsize=20", + "xft:Asana Math:pixelsize=20", + "xft:Noto Sans Symbols2", + "xft:FiraCode Nerd Font" + ] + , borderColor = "black" + , border = TopB + , bgColor = "#272822" + , fgColor = "grey" + , alpha = 255 + , position = Static { xpos = 0 , ypos = 0, width = 1920, height = 40 } + , textOffset = -1 + , iconOffset = -1 + , lowerOnStart = True + , pickBroadest = False + , persistent = False + , hideOnStart = False + , allDesktops = True + , overrideRedirect = True + , commands = [ + + Run Network "${networkCard}" + [ + "-t", "↑", + "-L","0", + "-H","32", + "--normal","green", + "--high","red" + ] 10, + + Run Memory ["-t","%"] 10, + Run Swap ["-t", "%"] 100, + Run Date "%a %_d %b - %H:%M - W%W" "date" 10, + Run Com "${./scripts/mpd_status.sh}" [] "mpc" 10, + -- Run Com "${./scripts/wireless.sh}" [] "wi" 100, + Run Com "${./scripts/volume.py}" [] "vol" 10, + Run UnsafeStdinReader, + Run DiskU [ + ${ lib.concatStringsSep ",\n" (map (d: ''("${d}", "[/]")'') disks) } + ] + ["-L", "20", "-H", "50", "-m", "1", "-p", "3", + "--low", "#a6e22e", + "--normal", "#f8f8f2", + "--high", "#f92672"] 20, + + Run Battery + [ + "-t", " (%)", + "--Low", "20", + "--High", "50", + "--low", "red", + "--normal", "yellow", + "--high", "green", + "--", + "-O", "🔌", + "-i", "🔌", + "-o", "🔋" + ] 50 + + ] + , sepChar = "%" + , alignSep = "}{" + , template = " %mpc% %UnsafeStdinReader% }\ + \ %date% \ + \{ %disku% | 🐏 %memory% | %${networkCard}% | %vol% " + } + ''; + + }; +} diff --git a/programs/xmobar/lambda.xpm b/programs/xmobar/lambda.xpm new file mode 100644 index 0000000..cc511eb --- /dev/null +++ b/programs/xmobar/lambda.xpm @@ -0,0 +1,48 @@ +/* XPM */ +static char * lambda_30_xpm[] = { +"42 30 4 1", +" c None", +/* White/Red */ +". c #b1b1b1", +"+ c #f10351", +"@ c #c0c0c0", + +/* Red/Orange/Yellow */ +/* ". c #ad2000", */ +/* "+ c #ff6c00", */ +/* "@ c #fec613", */ + +/* Purple */ +/* ". c #453A62", */ +/* "+ c #5E5086", */ +/* "@ c #8F4E8B", */ +"........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ ", +" ........ ++++++++ @@@@@@@@@@@@@@@@", +" ........ ++++++++ @@@@@@@@@@@@@@@@", +" ........ ++++++++ @@@@@@@@@@@@@@@", +" ........ ++++++++ @@@@@@@@@@@@@@@", +" ........ ++++++++ @@@@@@@@@@@@@@", +" ........ ++++++++ @@@@@@@@@@@@@", +" ........ ++++++++ ", +" ........ +++++++++ ", +" ........ ++++++++++ @@@@@@@@@@@@", +" ........ +++++++++++ @@@@@@@@@@@", +" ........ +++++++++++++ @@@@@@@@@@", +" ........ ++++++++++++++ @@@@@@@@@@", +" ........ +++++++++++++++ @@@@@@@@@", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +" ........ ++++++++ ++++++++ ", +"........ ++++++++ ++++++++ "}; diff --git a/programs/xmobar/scripts/mpd_status.sh b/programs/xmobar/scripts/mpd_status.sh new file mode 100755 index 0000000..e1e6daf --- /dev/null +++ b/programs/xmobar/scripts/mpd_status.sh @@ -0,0 +1,18 @@ +MPD_STATUS=$(mpc 2>/dev/null | sed -n '2{p;q}' | cut -d ' ' -f1) +case "$MPD_STATUS" in + "[playing]") + echo "▶" + # echo "[行]" + exit 0 + ;; + "[paused]") + echo "⏸" + # echo "[止]" + exit 0 + ;; + *) + echo "⏼" + # echo "[無]" + exit 0 + ;; +esac diff --git a/programs/xmobar/scripts/volume.py b/programs/xmobar/scripts/volume.py new file mode 100755 index 0000000..2bfca7f --- /dev/null +++ b/programs/xmobar/scripts/volume.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +import subprocess + +USE_SYMBOLS = True +VOLUME_COMMAND = 'amixer get Master'.split(' ') +VOLUME_SYMBOLS = { + "0": "𝒫", # "∅" + "10": "−", + "20": "=", + "30": "≡", + "40": "∫", + "50": "∮", + "60": "∬", + "70": "∯", + "80": "∭", + "90": "∰", + "100": "⨌", +} + +def get_volume(): + volumeData = subprocess \ + .check_output(VOLUME_COMMAND) \ + .decode() \ + .split('\n')[5] \ + .strip() \ + .split(' ') + + volume_level = int(volumeData[-2][1:-2]) + + if USE_SYMBOLS: + volume = VOLUME_SYMBOLS[str((volume_level // 10) * 10)] + if volumeData[-1] == '[off]': + volume = 'Ψ' + else: + volume = f'{volume_level}%' + if volumeData[-1] == '[off]': + volume = 'M' + + return volume + +if __name__ == '__main__': + print(get_volume()) diff --git a/programs/xmobar/scripts/wireless.sh b/programs/xmobar/scripts/wireless.sh new file mode 100755 index 0000000..10dd738 --- /dev/null +++ b/programs/xmobar/scripts/wireless.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +NETWORK_CARD=$(ip -br link | grep UP | grep -v lo | head -n 1 | awk '{print $1}') + +iwconfig $NETWORK_CARD 2>&1 | grep -q no\ wireless\ extensions\. && { + echo wired + exit 0 +} + +essid=`iwconfig $NETWORK_CARD | awk -F '"' '/ESSID/ {print $2}'` +stngth=`iwconfig $NETWORK_CARD | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1` +bars=`expr $stngth / 20` + +case $bars in +# 0) bar='[-----]' ;; +# 1) bar='[/----]' ;; +# 2) bar='[//---]' ;; +# 3) bar='[///--]' ;; +# 4) bar='[////-]' ;; +# 5) bar='[/////]' ;; +# *) bar='[--!--]' ;; + 0) bar='[〇]' ;; + 1) bar='[壱]' ;; + 2) bar='[弐]' ;; + 3) bar='[参]' ;; + 4) bar='[肆]' ;; + 5) bar='[伍]' ;; + *) bar='[無]' ;; +esac + +echo "$essid $bar" + +exit 0