Update bar
This commit is contained in:
parent
3813989cf0
commit
89e7ee5166
@ -38,9 +38,9 @@ in {
|
||||
interval=60
|
||||
markup=pango
|
||||
'' + genIniOrdered (optional (!isNull config.secrets.mail) (scr "email")
|
||||
++ [ (scrint "weather" 600) (scr "calendar") (scr "emacs") ]
|
||||
++ [ (scrint "weather" 600) (scr "calendar") (scr "emacs") (scr "nixos") ]
|
||||
++ optional (!isNull config.secrets.wage) (scrint "youtrack-wage" 3600)
|
||||
++ [ (scrint "music" 10) (scrint "sound" 5) ] ++ [
|
||||
++ [ (scrint "music" 3) (scrint "sound" 1) ] ++ [
|
||||
(scrint "cpu" 5)
|
||||
(scrint "freq" 10)
|
||||
(scr "temperature")
|
||||
@ -50,5 +50,5 @@ in {
|
||||
(scrint "brightness" 5)
|
||||
]
|
||||
++ optional (config.deviceSpecific.devInfo ? bigScreen) (scrint "network" 1)
|
||||
++ [ (scrint "connections" 10) (scr "df") (scr "date") (scrint "time" 1) ]);
|
||||
++ [ (scrint "bluetooth" 3) (scrint "connections" 3) (scr "df") (scr "date") (scrint "time" 1) ]);
|
||||
}
|
||||
|
@ -5,18 +5,18 @@
|
||||
CHARGE=`awk -F'[,%] ' '{print $2}' <<< "$BATTERY" | tr -d "%"`
|
||||
TIME=`awk -F', ' '{print $3}' <<< "$BATTERY" | cut -d " " -f 1 | cut -d: -f1-2`
|
||||
case "$STATUS" in
|
||||
Full) ;& "Not charging") icon=; TEXT="FULL"; status=0
|
||||
Full) ;& "Not charging") icon=; TEXT="FULL"; status=0
|
||||
;;
|
||||
Charging)
|
||||
TEXT="$CHARGE% ($TIME)"
|
||||
status=0
|
||||
case $CHARGE in
|
||||
[2-3]*) icon=;;
|
||||
[4-5]*) icon=;;
|
||||
[6-7]*) icon=;;
|
||||
[8-9]*) icon=;;
|
||||
100) icon=;;
|
||||
*) icon=;;
|
||||
[2-3]*) icon=;;
|
||||
[4-5]*) icon=;;
|
||||
[6-7]*) icon=;;
|
||||
[8-9]*) icon=;;
|
||||
100) icon=;;
|
||||
*) icon=;;
|
||||
esac
|
||||
;;
|
||||
Discharging)
|
||||
@ -28,17 +28,17 @@
|
||||
fi
|
||||
TEXT="$CHARGE% ($TIME)";
|
||||
case $CHARGE in
|
||||
1?) icon=;;
|
||||
2?) icon=;;
|
||||
3?) icon=;;
|
||||
4?) icon=;;
|
||||
5?) icon=;;
|
||||
6?) icon=;;
|
||||
7?) icon=;;
|
||||
8?) icon=;;
|
||||
9?) icon=;;
|
||||
100) icon=;;
|
||||
*) ;;
|
||||
1?) icon=;;
|
||||
2?) icon=;;
|
||||
3?) icon=;;
|
||||
4?) icon=;;
|
||||
5?) icon=;;
|
||||
6?) icon=;;
|
||||
7?) icon=;;
|
||||
8?) icon=;;
|
||||
9?) icon=;;
|
||||
100) icon=;;
|
||||
*) ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
21
modules/workspace/i3blocks/scripts/bluetooth.nix
Normal file
21
modules/workspace/i3blocks/scripts/bluetooth.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ iconfont, bash, bluez, pulseaudio, utillinux, ... }:
|
||||
''
|
||||
#!${bash}/bin/bash
|
||||
if ${utillinux}/bin/rfkill | grep bluetooth > /dev/null; then
|
||||
if ${utillinux}/bin/rfkill | grep bluetooth | grep blocked > /dev/null; then
|
||||
if ${bluez}/bin/bluetoothctl info > /dev/null; then
|
||||
if ${pulseaudio}/bin/pactl list sinks | grep bluez > /dev/null; then
|
||||
echo ""
|
||||
exit 33
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
else
|
||||
echo ""
|
||||
exit 33
|
||||
fi
|
||||
fi
|
||||
''
|
@ -5,56 +5,58 @@
|
||||
for connection in $CONNECTIONS
|
||||
do
|
||||
grep wifi <<< $connection > /dev/null && {
|
||||
SIGNAL=$(${networkmanager}/bin/nmcli d w | grep '^\*' | tr -s ' ' | cut -d' ' -f7)
|
||||
if [[ $SIGNAL -lt 20 ]]
|
||||
then
|
||||
text+=冷
|
||||
elif [[ $SIGNAL -lt 40 ]]
|
||||
then
|
||||
text+=爛
|
||||
elif [[ $SIGNAL -lt 60 ]]
|
||||
then
|
||||
text+=嵐
|
||||
elif [[ $SIGNAL -lt 80 ]]
|
||||
then
|
||||
text+=襤
|
||||
else
|
||||
text+=蠟
|
||||
fi
|
||||
# SIGNAL=$(${networkmanager}/bin/nmcli d w | grep '^\*' | tr -s ' ' | cut -d' ' -f7)
|
||||
# if [[ $SIGNAL -lt 20 ]]
|
||||
# then
|
||||
# text+=冷
|
||||
# elif [[ $SIGNAL -lt 40 ]]
|
||||
# then
|
||||
# text+=爛
|
||||
# elif [[ $SIGNAL -lt 60 ]]
|
||||
# then
|
||||
# text+=嵐
|
||||
# elif [[ $SIGNAL -lt 80 ]]
|
||||
# then
|
||||
# text+=襤
|
||||
# else
|
||||
# text+=蠟
|
||||
# fi
|
||||
text=
|
||||
}
|
||||
grep gsm <<< $connection >/dev/null && {
|
||||
MODEM=$(${modemmanager}/bin/mmcli -K -L | tail -1 | cut -d: -f2 | tr -d ' ')
|
||||
STATUS=$(${modemmanager}/bin/mmcli -K -m $MODEM)
|
||||
TECH=$(grep "modem.generic.access-technologies.value\[1\]" <<< $STATUS | cut -d: -f2 | tr -d ' ')
|
||||
|
||||
SIGNAL=$(grep "modem.generic.signal-quality.value" <<< $STATUS | cut -d: -f2 | tr -d ' ')
|
||||
if [[ $SIGNAL -lt 20 ]]
|
||||
then
|
||||
text+=""
|
||||
elif [[ $SIGNAL -lt 40 ]]
|
||||
then
|
||||
text+=""
|
||||
elif [[ $SIGNAL -lt 60 ]]
|
||||
then
|
||||
text+=""
|
||||
elif [[ $SIGNAL -lt 80 ]]
|
||||
then
|
||||
text+=""
|
||||
else
|
||||
text+=""
|
||||
fi
|
||||
# SIGNAL=$(grep "modem.generic.signal-quality.value" <<< $STATUS | cut -d: -f2 | tr -d ' ')
|
||||
# if [[ $SIGNAL -lt 20 ]]
|
||||
# then
|
||||
# text+=""
|
||||
# elif [[ $SIGNAL -lt 40 ]]
|
||||
# then
|
||||
# text+=""
|
||||
# elif [[ $SIGNAL -lt 60 ]]
|
||||
# then
|
||||
# text+=""
|
||||
# elif [[ $SIGNAL -lt 80 ]]
|
||||
# then
|
||||
# text+=""
|
||||
# else
|
||||
# text+=""
|
||||
# fi
|
||||
text+=
|
||||
if [[ $TECH == lte ]]
|
||||
then
|
||||
text+=""
|
||||
text+="ﰒ"
|
||||
else
|
||||
text+=""
|
||||
text+="ﰑ"
|
||||
fi
|
||||
}
|
||||
grep ethernet <<< $connection > /dev/null && text+=""
|
||||
grep ethernet <<< $connection > /dev/null && text+=""
|
||||
done
|
||||
code=0
|
||||
[[ $text == "" ]] && {
|
||||
text=
|
||||
text=
|
||||
code=33
|
||||
}
|
||||
echo "<span font='${iconfont}'>$text</span>"
|
||||
|
@ -1,33 +1,40 @@
|
||||
p: c:
|
||||
with p;
|
||||
builtins.mapAttrs (name: value:
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = value;
|
||||
unpackPhase = "true";
|
||||
buildInputs = [ghc];
|
||||
buildPhase = "ghc -o $out $src";
|
||||
installPhase = "true";
|
||||
}) {
|
||||
let
|
||||
iconfont = "Material Icons";
|
||||
buildHaskellScript = name: script:
|
||||
stdenv.mkDerivation {
|
||||
inherit name;
|
||||
src = script;
|
||||
unpackPhase = "true";
|
||||
buildInputs = [ghc];
|
||||
buildPhase = "ghc -o $out $src";
|
||||
installPhase = "true";
|
||||
ICONFONT = iconfont;
|
||||
};
|
||||
writeScript = name: script:
|
||||
writeTextFile {
|
||||
inherit name;
|
||||
text = callPackage script {
|
||||
inherit iconfont;
|
||||
config = c;
|
||||
};
|
||||
executable = true;
|
||||
checkPhase =
|
||||
"${bash}/bin/bash -n $src || ${python3}/bin/python3 -m compileall $src";
|
||||
};
|
||||
in
|
||||
builtins.mapAttrs buildHaskellScript {
|
||||
free = ./free.hs;
|
||||
temperature = ./temperature.hs;
|
||||
network = ./network.hs;
|
||||
} // builtins.mapAttrs (name: value:
|
||||
writeTextFile {
|
||||
inherit name;
|
||||
text = callPackage value {
|
||||
iconfont = "Material Design Icons";
|
||||
config = c;
|
||||
};
|
||||
executable = true;
|
||||
checkPhase =
|
||||
"${bash}/bin/bash -n $src || ${python3}/bin/python3 -m compileall $src";
|
||||
}) {
|
||||
} // builtins.mapAttrs writeScript {
|
||||
battery = ./battery.nix;
|
||||
brightness = ./brightness.nix;
|
||||
calendar = ./calendar.nix;
|
||||
email = ./email.nix;
|
||||
emacs = ./emacs.nix;
|
||||
bluetooth = ./bluetooth.nix;
|
||||
connections = ./connections.nix;
|
||||
weather = ./weather.nix;
|
||||
sound = ./sound.nix;
|
||||
@ -35,9 +42,10 @@ writeTextFile {
|
||||
youtrack-wage = ./youtrack-wage.nix;
|
||||
cpu = {...}: ''top -b -n1 -p 1 | fgrep "Cpu(s)" | tail -1 | awk -F'id,' -v prefix="$prefix" '{ split($1, vs, ","); v=vs[length(vs)]; sub("%", "", v); printf "%s%.1f%%\n", prefix, 100 - v }' '';
|
||||
freq = {...}: ''echo $(${pkgs.bc}/bin/bc -l <<< "scale=2; `cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq|sort|tail -1`/1000000") GHz'';
|
||||
df = {...}: ''echo '<span font="Material Icons 11"></span>' `df / | tail -1 | grep -o '..%'`'';
|
||||
date = {...}: "${pkgs.coreutils}/bin/date +'<span font=\"Material Icons 11\"></span> %a %y-%m-%d'";
|
||||
time = {...}: "${pkgs.coreutils}/bin/date +'<span font=\"Material Icons 11\"></span> %T'";
|
||||
df = {...}: ''echo '<span font="${iconfont}"></span>' `df / | tail -1 | grep -o '..%'`'';
|
||||
date = {...}: "${pkgs.coreutils}/bin/date +'<span font=\"${iconfont}\"></span> %a %y-%m-%d'";
|
||||
time = {...}: "${pkgs.coreutils}/bin/date +'<span font=\"${iconfont}\"></span> %T'";
|
||||
nixos = {...}: "echo -n '<span font=\"Material Icons 13\"></span>'; cat /run/current-system/nixos-version | cut -d. -f3";
|
||||
#temperature = ./temperature.nix;
|
||||
#free = ./free.nix;
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
{...}: ''
|
||||
[[ $BLOCK_BUTTON -eq 2 ]] && emacsclient --eval "(org-clock-out)" > /dev/null
|
||||
emacsclient --eval "org-mode-line-string" | head -1 | cut -d\" -f 2
|
||||
{ config, ... }:
|
||||
let ec = "${config.home-manager.users.balsoft.programs.emacs.finalPackage}/bin/emacsclient";
|
||||
in
|
||||
''
|
||||
[[ $BLOCK_BUTTON -eq 2 ]] && ${ec} --eval "(org-clock-out)" > /dev/null
|
||||
${ec} --eval "org-mode-line-string" | head -1 | cut -d\" -f 2
|
||||
''
|
||||
|
@ -5,6 +5,9 @@
|
||||
obj.login("${config.secrets.mail.user}@${config.secrets.mail.host}", "${config.secrets.mail.password}")
|
||||
obj.select()
|
||||
l = len(obj.search(None, 'unseen')[1][0].split())
|
||||
print('<span font="${iconfont}"></span> %s' % str(l))
|
||||
exit(33 if l != 0 else 0)
|
||||
if l == 0:
|
||||
print('')
|
||||
else:
|
||||
print('<span font="${iconfont}"></span> %s' % str(l))
|
||||
exit(33)
|
||||
''
|
||||
|
@ -8,12 +8,11 @@
|
||||
if BLOCK_BUTTON == "1": call(["${playerctl}/bin/playerctl", "play-pause"])
|
||||
if BLOCK_BUTTON == "2": call(["${playerctl}/bin/playerctl", "stop"])
|
||||
if BLOCK_BUTTON == "3": call(["${playerctl}/bin/playerctl", "next"])
|
||||
if status == "Paused":
|
||||
icon=""
|
||||
elif status == "Playing":
|
||||
icon=""
|
||||
if status == "Paused" or status == "Playing":
|
||||
text = getoutput("${playerctl}/bin/playerctl metadata title")[:20:]
|
||||
icon = ""
|
||||
else:
|
||||
icon = ""
|
||||
text = getoutput("${playerctl}/bin/playerctl metadata title")[:20:]
|
||||
text = ""
|
||||
icon = ""
|
||||
print("<span font='${iconfont}'>%s</span> %s" % (icon, text.replace('&', '&')))
|
||||
''
|
||||
|
@ -1,9 +1,12 @@
|
||||
{-# LANGUAGE BangPatterns #-}
|
||||
{-# LANGUAGE BangPatterns, TemplateHaskell #-}
|
||||
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.Monad (mapM)
|
||||
import Control.Monad (mapM, join)
|
||||
import System.Directory (listDirectory)
|
||||
import Data.Bool (bool)
|
||||
import Language.Haskell.TH.Syntax (liftString, runIO)
|
||||
import System.Environment (getEnv)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
|
||||
path :: String
|
||||
path = "/sys/class/net/"
|
||||
@ -17,7 +20,7 @@ instance Monoid Statistics where
|
||||
mempty = Statistics 0 0
|
||||
|
||||
icon :: String -> String
|
||||
icon i = "<span font='Material Icons 11'>" ++ i ++ "</span>"
|
||||
icon i = "<span font='"++ $(join $ liftIO $ liftString <$> getEnv "ICONFONT") ++ "'>" ++ i ++ "</span>"
|
||||
|
||||
readInterface :: FilePath -> IO Statistics
|
||||
readInterface interface = do
|
||||
|
@ -9,19 +9,19 @@
|
||||
then
|
||||
volume=""
|
||||
end=""
|
||||
icon=""
|
||||
icon="婢"
|
||||
else
|
||||
volume=`${pamixer}/bin/pamixer --get-volume`
|
||||
end="%"
|
||||
if [[ $volume -lt 33 ]]
|
||||
then
|
||||
icon=""
|
||||
icon="奄"
|
||||
else
|
||||
if [[ $volume -lt 66 ]]
|
||||
then
|
||||
icon=""
|
||||
icon="奔"
|
||||
else
|
||||
icon=""
|
||||
icon="墳"
|
||||
code=33
|
||||
fi
|
||||
fi
|
||||
|
@ -1,11 +1,19 @@
|
||||
{-# LANGUAGE TemplateHaskell, OverloadedStrings #-}
|
||||
|
||||
import Prelude hiding (readFile)
|
||||
import System.Directory
|
||||
import System.FilePath
|
||||
import Control.Monad (forM)
|
||||
import Control.Monad (forM, join)
|
||||
import System.Posix.Files
|
||||
import Data.List (isPrefixOf, isInfixOf)
|
||||
import System.Exit
|
||||
|
||||
|
||||
import Language.Haskell.TH.Syntax (liftString, runIO)
|
||||
import System.Environment (getEnv)
|
||||
import Control.Monad.IO.Class (liftIO)
|
||||
import Data.Maybe (catMaybes)
|
||||
import Control.Exception
|
||||
import Data.Text (unpack)
|
||||
import Data.Text.IO (readFile)
|
||||
|
||||
-- | Traverse from 'top' directory and return all the files by
|
||||
-- filtering with 'include' predicate.
|
||||
@ -31,7 +39,7 @@ getTemps = do
|
||||
-> ("hwmon" `isPrefixOf` name)
|
||||
|| ("temp" `isInfixOf` name) && ("input" `isInfixOf` name)
|
||||
)
|
||||
fmap (round .(/1000) . read) <$> traverse (readFile) hwmons
|
||||
fmap (round . (/1000) . read . unpack) <$> traverse (handle (\e -> do pure (e :: IOException); pure "0") . readFile) hwmons
|
||||
|
||||
-- | Get a symbol corresponding to the temperature
|
||||
getSymbol :: Integral n => n -> String
|
||||
@ -40,6 +48,9 @@ getSymbol t
|
||||
| t < 80 = "\57866" --
|
||||
| otherwise = "\57867" --
|
||||
|
||||
icon :: String -> String
|
||||
icon s = "<span font='"++ $(join $ liftIO $ liftString <$> getEnv "ICONFONT") ++ "'>" ++ s ++ "</span>"
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
maxTemp <- maximum <$> getTemps
|
||||
|
@ -1,6 +1,11 @@
|
||||
{ bash, yt-utilities, libqalculate, config, lib, ... }:
|
||||
let ec = config.home-manager.users.balsoft.programs.emacs.finalPackage;
|
||||
in
|
||||
''
|
||||
#!${bash}/bin/bash
|
||||
set -euo pipefail
|
||||
export PATH="$PATH:${yt-utilities}/bin:${ec}/bin:${libqalculate}/bin"
|
||||
|
||||
HOURS_DAY=$(yt org local --since $(date +'%Y-%m-%d') | tail -1)
|
||||
HOURS_MONTH=$(yt org local --since $(date +'%Y-%m-01') | tail -1)
|
||||
HOURS_YEAR=$(yt org local --since $(date +'%Y-01-01') | tail -1)
|
||||
|
Loading…
Reference in New Issue
Block a user