Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- output="<txt>"
- next="|||||||||"
- secondary_color="#5294e2"
- secondary_color="#4084d6"
- warning_color="#fea962"
- error_color="#FF4136"
- ##########################
- # MPD
- ##########################
- # if i try display title with '&' in name genmon stops updating
- mpd_title=$(mpc | head -1 | sed 's/&/and/g')
- mpd_status=$(mpc | head -2 | tail -1)
- if grep -q "playing" <<< "$mpd_status" ; then
- output="<click>mpc toggle</click>$output<span font=\"FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup> </sup></span> $mpd_title$next"
- # output="<img>/usr/share/icons/ArcPaper/actions/16/gtk-media-pause.png</img><click>mpc toggle</click>$output<span font=\"FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup> </sup></span> $mpd_title$next"
- elif grep -q "paused" <<< "$mpd_status" ; then
- output="<img>/usr/share/icons/ArcPaper/actions/16/gtk-media-play-ltr.png</img><click>mpc toggle</click>$output<span font=\"FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup> </sup></span><span fgcolor=\"$warning_color\"> $mpd_title</span>$next"
- fi
- ##########################
- # Battery
- ##########################
- if [ $(ls /sys/class/power_supply | grep BAT | wc -l) -gt 0 ]; then
- battery_directory="/sys/class/power_supply/"$(ls /sys/class/power_supply | grep BAT | head -1)"/"
- energy_now=$(<$battery_directory"/charge_now")
- energy_full=$(<$battery_directory"/charge_full")
- battery_color=""
- charge=$(($energy_now*100))
- charge=$(($charge/$energy_full))
- # if [ "90" -gt "$charge" ]; then
- # battery_color="color=\"da2818\""
- # output=$output"DSADAS"
- # fi
- status=$(<$battery_directory"/status")
- charge="<span font=\"SFNS Text Bold, FontAwesome 9\" weight=\"heavy\" fgcolor=\"$secondary_color\"><sup> </sup></span> "$charge"%"
- output="$output$charge$next"
- fi
- ##########################
- # RAM
- ##########################
- freememory=$(free | tail -2 | head -1 | awk '{print $3/$2 * 100.0}' | awk '{printf("%d\n",$1 + 0.5)}' )
- if (( $freememory > 80 )); then
- freememory="<span weight=\"heavy\" fgcolor=\"$error_color\" font=\"FontAwesome 9\"><sup> </sup></span> $freememory%"
- elif (( $freememory > 50 )); then
- freememory="<span weight=\"heavy\" fgcolor=\"$warning_color\" font=\"FontAwesome 9\"><sup> </sup></span> $freememory%"
- else
- freememory="<span weight=\"heavy\" fgcolor=\"$secondary_color\" font=\"FontAwesome 9\"><sup> </sup></span> $freememory%"
- fi
- output="$output$freememory$next"
- ##########################
- # CPU
- ##########################
- cpu_usage=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage }' | awk '{printf("%d\n",$1 + 0.5)}' )
- if (( $cpu_usage > 80 )); then
- cpu_usage="<span weight=\"heavy\" fgcolor=\"$error_color\" font=\"FontAwesome 9\"><sup> </sup></span> $cpu_usage%"
- elif (( $cpu_usage > 40 )); then
- cpu_usage="<span weight=\"heavy\" fgcolor=\"$warning_color\" font=\"FontAwesome 9\"><sup> </sup></span> $cpu_usage%"
- else
- cpu_usage="<span weight=\"heavy\" fgcolor=\"$secondary_color\" font=\"FontAwesome 9\"><sup> </sup></span> $cpu_usage%"
- fi
- output="$output$cpu_usage$next"
- ##########################
- # HDD
- ##########################
- hdd_free=$(df --output=avail -h / | tail -n 1 | tr -d ' ')
- if [[ $hdd_free == *"G"* ]]
- then
- hdd_free=$(echo $hdd_free | sed 's/G/ GB/g')
- fi
- if [[ $hdd_free == *"M"* ]]
- then
- hdd_free=$(echo $hdd_free | sed 's/M/ MB/g')
- fi
- hdd_free="<span weight=\"heavy\" fgcolor=\"$secondary_color\" font=\"FontAwesome 9\"><sup> </sup></span> "$hdd_free
- output="$output$hdd_free$next"
- ##########################
- # DATE
- ##########################
- date_without_month=$(date +"%H:%M, %d")
- month=$(date +"%m")
- set_month_roman=false
- if $set_month_roman
- then
- case "$month" in
- "01") month="I" ;;
- "02") month="II" ;;
- "03") month="III" ;;
- "04") month="IV" ;;
- "05") month="V" ;;
- "06") month="VI" ;;
- "07") month="VII" ;;
- "08") month="VIII" ;;
- "09") month="IX" ;;
- "10") month="X" ;;
- "11") month="XI" ;;
- "12") month="XII" ;;
- *) month="XD"
- esac
- else
- case "$month" in
- "01") month="stycznia" ;;
- "02") month="lutego" ;;
- "03") month="marca" ;;
- "04") month="kwietnia" ;;
- "05") month="maja" ;;
- "06") month="czerwca" ;;
- "07") month="lipca" ;;
- "08") month="sierpnia" ;;
- "09") month="września" ;;
- "10") month="października" ;;
- "11") month="listopada" ;;
- "12") month="grudnia" ;;
- *) month="nietzschego"
- esac
- fi
- #output="$output$date_without_month $month$next"
- output=$(echo $output | sed 's/'$next'/ • /g')
- output=${output::-7}"</txt>"
- echo -e "$output"
Advertisement
Add Comment
Please, Sign In to add comment