scripts

various script and utils
git clone git://z3bra.org/scripts
Log | Files | Refs

commit 4ac8555aa7405a70051c3826f1572a0ebda17549
parent e44498c88afcf217ef06b947875212d782dc1809
Author: Willy Goiffon <w.goiffon@gmail.com>
Date:   Mon Jul  8 11:29:28 +0200

added GPU informations (temperature, fan speed)

Diffstat:
bar/config.sh | 59++++++++++++++++++++++++++++++++++++++---------------------
bar/status.sh | 43++++++++++++++++++++++++++++++++-----------
2 files changed, 70 insertions(+), 32 deletions(-)
diff --git a/bar/config.sh b/bar/config.sh @@ -13,14 +13,17 @@ # * 9 : white # unified colors -bg="1" -fg="9" -hl="0" -dk="2" +bg="0" +fg="1" +hl="2" +dk="3" # separator sp="\f${dk}$(echo -e '\ue190')\fr " +# delimiter (between icon and value) +dl=" " + # path to executable bar="/usr/bin/bar -b" @@ -30,20 +33,34 @@ fifo=/tmp/bar.fifo # refresh frenquency (in seconds) refresh=0.75 -# info icons (from stlarch_font package. use gbdef to view/modify font) -i_arch='\ue0a1' # arch logo -# i_pkgs='\ue14d' # pacman -i_pkgs='\ue0aa' # pacman ghost -i_mail='\ue072' # mail icon -i_wifi='\ue0f0' # signal -i_netw='\ue149' # wired -i_time='\ue017' # clock -# i_batt='\ue040' # thunder -i_batt='\ue10c' # power -i_load='\ue021' # micro chip -i_memy='\ue145' # floppy -i_musk='\ue04d' # headphones -i_alsa='\ue05d' # speaker +# info icons (from stlarch_font package. use gbdfed to view/modify font) +# i_arch='\ue0a1' # arch logo +# # i_pkgs='\ue14d' # pacman +# i_pkgs='\ue0aa' # pacman ghost +# i_mail='\ue072' # mail icon +# i_wifi='\ue0f0' # signal +# i_netw='\ue149' # wired +# i_time='\ue017' # clock +# # i_batt='\ue040' # thunder +# i_batt='\ue10c' # power +# i_load='\ue021' # micro chip +# i_memy='\ue145' # floppy +# i_musk='\ue04d' # headphones +# i_alsa='\ue05d' # speaker +i_arch='SYS' +i_pkgs='PKG' +i_mail='MSG' +i_wifi='SIG' +i_netw='NET' +# i_time='CLK' +i_batt='BAT' +i_load='CPU' +i_memy='RAM' +i_grap='GPU' +i_fans='FAN' +i_musk='CUR' +i_alsa='VOL' +i_time="$(date +%m/%d)" # clock # workspace icons / names i_trm=$(echo -e '\ue09f') # default @@ -68,17 +85,17 @@ mpc_format='[[%artist% - ]%title%]|[%file%]' alsa_channel='Master' # define you own interfaces -net_wire='enp2s0' +net_wire='enp4s0' net_wifi='enp3s0' # which interface do you want to use ? net_interface=$net_wire # Only the time ? with seconds ? Maybe the current year...? -date_format="%H:%M:%S" +date_format="%H:%M" # used to get current workspace wm_lib_xcb="XCB" # DO NOT MODIFY wm_lib_xlib="XLIB" # DO NOT MODIFY -wm_lib=$wm_lib_xcb # which library does your WM use ? +wm_lib=$wm_lib_xcb # which library does your WM use ? # xcb *should* work with any WM, as it uses `xprop`, whereas # xlib uses `wmctrl` which works ONLY with Xlib. diff --git a/bar/status.sh b/bar/status.sh @@ -5,8 +5,8 @@ source $(dirname $0)/config.sh # print formatted output. need 2 params: display <value> <icon> function display () { echo -n "\f${hl}" - echo -ne "$2 " - echo "\f${fg}$1" + echo -ne "$2" + echo "${dl}\f${fg}$1" } function workspaces () { @@ -22,7 +22,7 @@ function workspaces () { for w in $(seq 0 $dskp_num); do if [ "$w" -eq "$dskp_cur" ]; then - buffer="$buffer\u${hl} ${dskp_tag[$w]} \u${bg}" + buffer="$buffer\u${fg} ${dskp_tag[$w]} \u${bg}" else buffer="$buffer ${dskp_tag[$w]} " fi @@ -71,6 +71,22 @@ function memory () { display "$val" "$ico" } +function gputemp () { + + val="$(nvidia-smi -q -d TEMPERATURE | grep Gpu | sed 's/.*: //')" + ico=${i_grap} + + display "$val" "$ico" +} + +function gpufanspeed () { + + val="$(nvidia-smi -q | grep "Fan" | sed 's/.*: \([0-9]*\).*$/\1/')%" + ico=${i_fans} + + display "$val" "$ico" +} + function processes () { val="$(iostat -c | sed -n "4p" | awk -F " " '{print $1}')%" @@ -88,13 +104,16 @@ function network () { ico=${i_netw} else - net_interface=$(ip link| grep 'state UP'| sed 's/[0-9]: \([^:]*\):.*$/\1/') + net_interface=$(ip link| grep 'state UP'| + sed 's/[0-9]: \([^:]*\):.*$/\1/') if [ "$net_interface" = "$net_wire" ]; then - val=$(ip addr show $net_interface| grep 'inet '| head -n1| awk '{print $2}') + val=$(ip addr show $net_interface| grep 'inet '| + sed 's#.* \(.*\)/.*$#\1#') ico=${i_netw} elif [ "$net_interface" = "$net_wifi" ]; then - val=$(ip addr show $net_interface| grep 'inet '| head -n1| awk '{print $2}') - ico=${i_netw} + val=$(ip addr show $net_interface| grep 'inet '| + sed 's#.* \(.*\)/.*$#\1#') + ico=${i_wifi} else val="" ico=${i_netw} @@ -116,13 +135,15 @@ function clock () { function fillbar () { buffer="\b${bg}\f${fg}" buffer="$buffer\l\u${bg}" - buffer="$buffer$(workspaces) " - buffer="$buffer\c\u${bg}" buffer="$buffer$(volume) ${sp}" buffer="$buffer$(mpd_now_playing) " + buffer="$buffer\c\u${bg}" + buffer="$buffer$(workspaces) " buffer="$buffer\r\u${bg}" - buffer="$buffer$(network) ${sp}" + # buffer="$buffer$(network) ${sp}" buffer="$buffer$(memory) ${sp}" + buffer="$buffer$(gputemp) ${sp}" + buffer="$buffer$(gpufanspeed) ${sp}" buffer="$buffer$(processes) ${sp}" buffer="$buffer$(packages) ${sp}" buffer="$buffer$(clock)" @@ -133,5 +154,5 @@ function fillbar () { while :; do source $(dirname $0)/config.sh fillbar - sleep ${refresh} + sleep ${refresh} done | ${bar}