diff --git a/blocks.def.h b/blocks.def.h index 9c22d68..accc629 100644 --- a/blocks.def.h +++ b/blocks.def.h @@ -1,9 +1,12 @@ //Modify this file to change what commands output to your statusbar, and recompile using the make command. static const Block blocks[] = { - /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ - {"Mem:", "free -h | awk '/^Mem/ { print $3\"/\"$2 }' | sed s/i//g", 30, 0}, - - {"", "date '+%b %d (%a) %I:%M%p'", 5, 0}, + /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ + { " 🌐 ", "/opt/dwmblocks_scripts/dwm_ipaddr", 30, 0 }, + { " 🐧 ", "/opt/dwmblocks_scripts/dwm_kernel", 360, 2 }, + { " đŸ’ģ ", "/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. diff --git a/dwmblocks_scripts/dwm_battery b/dwmblocks_scripts/dwm_battery new file mode 100755 index 0000000..1fd9c31 --- /dev/null +++ b/dwmblocks_scripts/dwm_battery @@ -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 \ No newline at end of file diff --git a/dwmblocks_scripts/dwm_ipaddr b/dwmblocks_scripts/dwm_ipaddr new file mode 100755 index 0000000..4598eaf --- /dev/null +++ b/dwmblocks_scripts/dwm_ipaddr @@ -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" \ No newline at end of file diff --git a/dwmblocks_scripts/dwm_kernel b/dwmblocks_scripts/dwm_kernel new file mode 100755 index 0000000..d543706 --- /dev/null +++ b/dwmblocks_scripts/dwm_kernel @@ -0,0 +1,5 @@ +#!/bin/sh + +kern="$(uname -r | sed -re 's/(^[0-9]*\.[0-9]*\.[0-9]*-[0-9]*)(.*)/\1/')" +echo -e "$kern " + diff --git a/dwmblocks_scripts/dwm_memory b/dwmblocks_scripts/dwm_memory new file mode 100755 index 0000000..f70e223 --- /dev/null +++ b/dwmblocks_scripts/dwm_memory @@ -0,0 +1,5 @@ +#!/bin/sh + +mem="$(free -h | awk '/^Mem:/ {print $3 "/" $2}')" +echo -e "$mem" + diff --git a/dwmblocks_scripts/dwm_volume b/dwmblocks_scripts/dwm_volume new file mode 100755 index 0000000..bc5469c --- /dev/null +++ b/dwmblocks_scripts/dwm_volume @@ -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"