my dwmblocks setup

This commit is contained in:
Filip Rojek 2022-11-09 20:00:41 +01:00
parent a933ce0d61
commit 1528bb5fc9
6 changed files with 70 additions and 4 deletions

View File

@ -1,9 +1,12 @@
//Modify this file to change what commands output to your statusbar, and recompile using the make command. //Modify this file to change what commands output to your statusbar, and recompile using the make command.
static const Block blocks[] = { static const Block blocks[] = {
/*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/
{"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, { " 🌐 ", "/opt/dwmblocks_scripts/dwm_ipaddr", 30, 0 },
{ " 🐧 ", "/opt/dwmblocks_scripts/dwm_kernel", 360, 2 },
{"", "date '+%b %d (%a) %I:%M%p'", 5, 0}, { " 💻 ", "/opt/dwmblocks_scripts/dwm_memory", 30, 0 },
{ "", "/opt/dwmblocks_scripts/dwm_volume withicon", 1, 10 },
{ "", "/opt/dwmblocks_scripts/dwm_battery withicon", 1, 10 },
{ "", "date '+%b %d (%a) %I:%M:%S %p'", 1, 0 },
}; };
//sets delimeter between status commands. NULL character ('\0') means no delimeter. //sets delimeter between status commands. NULL character ('\0') means no delimeter.

23
dwmblocks_scripts/dwm_battery Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
prct=$(upower -d | grep percentage | sed -n "1p" | sed -e 's/^.* //')
prctonly=$(upower -d | grep percentage | sed -n "1p" | sed -e 's/^.* //' | sed 's/%//')
stat=$(upower -d | grep -m1 state | sed -e 's/^.* //')
## if any argument
if [ $# -gt 0 ]; then
if [[ $stat == "charging" ]]; then
echo " ⚡ $prct"
exit
fi
if [[ $prctonly -gt 30 ]]; then
echo " 🔋 $prct"
exit
fi
echo " 🪫 $prct"
exit
fi
echo $prct

11
dwmblocks_scripts/dwm_ipaddr Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
eth="$(ip -4 addr show enp8s0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"
wlp="$(ip -4 addr show wlp7s0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')"
if [[ $(echo $eth | wc -c) -gt 1 ]]
then
echo "$eth"
exit;
fi
echo "$wlp"

5
dwmblocks_scripts/dwm_kernel Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
kern="$(uname -r | sed -re 's/(^[0-9]*\.[0-9]*\.[0-9]*-[0-9]*)(.*)/\1/')"
echo -e "$kern "

5
dwmblocks_scripts/dwm_memory Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
mem="$(free -h | awk '/^Mem:/ {print $3 "/" $2}')"
echo -e "$mem"

19
dwmblocks_scripts/dwm_volume Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
vol="$(amixer get Master | tail -n1 | sed -r 's/.*\[(.*)%\].*/\1/')"
## if any argument
if [ $# -gt 0 ]; then
stat="$(amixer get Master | tail -n1 | sed -r 's/.*\[(.*)].*/\1/')"
if [[ $(echo $stat) == "on" ]]; then
echo " 🔊 $vol"
exit
fi
echo " 🔇 $vol"
exit
fi
## just returns volume %
vol="$(amixer get Master | tail -n1 | sed -r 's/.*\[(.*)%\].*/\1/')"
echo -e "$vol"