Categories
Latest Posts
Running Cromwell on AWS/Batch
- Posted: 2018-11-21.
Parallel mysql myisam repair
- Posted: 2018-11-21.
Does a TKI like Crizotinib kill tumor cells ?
- Posted: 2018-10-28.
Save Spotify to flac or mp3
- Posted: 2018-07-14.
Replace all symlinks by the original file
- Posted: 2018-03-02.
Tag Collection
Password python BASH SLURM cotd Remote Recovery Searching R Paired-End whitespace docker natbib indent spotify torque/pbs Batch CPAN apoptosis mysql windows dos2unix Silverlight PHP ExecOnCommand Yelo.tv cromwell Headless VMware NSCLC api galaxy preamble Conky fuzzy match telenet VMplayer spam bioinformatics mpd Perl compress todo.txt proftpd XFS levenshtein timer Rcran Apache drmaa antialias terraform fancy tikz javascript Installation Literature FTP bibtex Image AWS NGS TrainOfThought GATK NFS sudoers Ubuntu line-end Typesetting cloudformation Cluster osd_cat Linespacing HPC LaTeX
Log in
Conky configuration with spotify, mpd, torque monitor and todo list.
Posted on 2013-01-30 15:48:04
by Geert Vandeweyer
Loading Content
Conky configuration with spotify, mpd, torque monitor and todo list.
Posted on 2013-01-30 15:48:04
by Geert Vandeweyer
For my own reference, and for those that might need it, this is my conky configuration and accessory scripts.
1. Main .conkyrc file
alignment top_left background no cpu_avg_samples 2 default_color 232323 default_outline_color white default_shade_color white double_buffer yes draw_borders no draw_graph_borders yes draw_outline no draw_shades no gap_x 1585 gap_y 5 maximum_width 330 max_port_monitor_connections 64 max_specials 512 max_user_text 16384 minimum_size 330 10 net_avg_samples 2 no_buffers yes out_to_console no #wm_class_name Conky #own_window_colour black own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager own_window_transparent yes own_window_type normal own_window yes stippled_borders 2 update_interval 1 uppercase no use_xft yes xftalpha 0.8 xftfont Bitstream Vera Sans Mono:size=9 top_cpu_separate true # colours color1 aeaeae # light blue color2 6892C6 # orange #E77320 color3 FC8820 # green color4 78BF39 # red color5 CC0000 text_buffer_size 2048 TEXT ${font bold:italic}${color Red}$nodename ${color DimGray}${hr 2} $font${color white}Uptime:$color $uptime ${alignr}${color white} Load:$color $loadavg $font${color white}Power: $color ${battery} ${alignr}${if_match "$battery_time" == ""}${color white}Status:$color On-line${else}${color white}Remaining:$color $battery_time${endif} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}CPU's$font ${color DimGray}${hr 2} ${color white}Core 1:$color ${execi 5 sensors | grep "Core 0" | cut -d "+" -f2 | cut -c1-7} (${freq_g 1}GHz) ${cpubar cpu1 5,85} (${freq_g 2}GHz) ${cpubar cpu2 5,85} ${color white}Core 2:$color ${execi 5 sensors | grep "Core 1" | cut -d "+" -f2 | cut -c1-7} (${freq_g 3}GHz) ${cpubar cpu3 5,85} (${freq_g 4}GHz) ${cpubar cpu4 5,85} ${color white}Core 3:$color ${execi 5 sensors | grep "Core 2" | cut -d "+" -f2 | cut -c1-7} (${freq_g 5}GHz) ${cpubar cpu5 5,85} (${freq_g 6}GHz) ${cpubar cpu6 5,85} ${color white}Core 4:$color ${execi 5 sensors | grep "Core 3" | cut -d "+" -f2 | cut -c1-7} (${freq_g 7}GHz) ${cpubar cpu7 5,85} (${freq_g 8}GHz) ${cpubar cpu8 5,85} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Memory$font ${color DimGray}${hr 2} ${color white}RAM Usage:$color $mem/$memmax ${alignr}$memperc% ${membar 5,85} ${color white}Swap Usage:$color $swap/$swapmax ${alignr}$swapperc% ${swapbar 5,85} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}File Systems$font ${color DimGray}${hr 2} ${color white}Disk I/O: $color ${diskio} ${color white}HD Temp:$color ${hddtemp /dev/sda}°C ${color white}/ $color${fs_used /}/${fs_size /}${alignr}${fs_bar 5,120 /} ${color white}/home $color${fs_used /home}/${fs_size /home}${alignr}${fs_bar 5,120 /home} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Network$font ${color DimGray}${hr 2} ${color white}Wired Down:$color ${downspeedf eth0} k/s $alignr${color white}Wired Up:$color ${upspeedf eth0} k/s ${downspeedgraph eth0 32,155 696969 696969} $alignr${upspeedgraph eth0 32,155 696969 696969} ${color white}Wlan Down:$color ${downspeedf wlan0} k/s $alignr${color white}Wlan Up:$color ${upspeedf wlan0} k/s ${downspeedgraph wlan0 32,155 696969 696969} $alignr${upspeedgraph wlan0 32,155 696969 696969} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Top Processes$font ${color DimGray}${hr 2} ${color D90000} CPU$alignr Memory $color ${top cpu 1}%: ${top name 1} $alignr${top_mem mem 1}%: ${top_mem name 1} $color ${top cpu 2}%: ${top name 2} $alignr${top_mem mem 2}%: ${top_mem name 2} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Music Player$font ${color DimGray}${hr 2} ${if_running spotify}${texeci 1 ~/bin/conky.spotify.nowplaying.work.sh}$color Spotify ${execi 1 expr "`qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus`"}: ${exec cat ~/.cache/spotify-nowplaying-elapsed-pretty}/${exec cat ~/.cache/spotify-nowplaying-length-pretty} ${color}${exec cat ~/.cache/spotify-nowplaying}${else}${if_mpd_playing}$color MPD Playing: (${mpd_elapsed}/${mpd_length}) - Random: ${mpd_random} Artist: ${if_match ${execi 5 expr length "`mpc --format %artist% | head -n 1`"} >= 50}${scroll 50 3 ${mpd_artist}}${else}${mpd_artist}${endif} Title: ${mpd_track}.${if_match ${execi 5 expr length "`mpc --format %title% | head -n 1`"} >= 50}${scroll 50 3 ${mpd_title}}${else}${mpd_title}${endif} Album: ${if_match ${execi 5 expr length "`mpc --format %album% | head -n 1`"} >= 50}${scroll 50 3 ${mpd_album}}${else}${mpd_album}${endif}${else} No Media Playing ${endif}${endif} ${execpi 120 perl /home/gvandeweyer/bin/conky.todo.pl} ${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Cluster Status$font ${color DimGray}${hr 2} $color${execi 30 expr "`cat ~/.conky_clusterstat.txt`"} ${color DimGray}${hr 2}
2. Conky Launcher
I have the following set to launch after loading of KDE.
#!/bin/bash # start conky conky -& sleep 3 # set the correct background for desktop integration feh --bg-scale /home/gvandeweyer/Pictures/zim_gray.png
3. Spotify information
Adapted from snippets around the web. My main contribution was to include correct timing when spotify is paused.
conky.spotify.nowplaying.work.sh:
#!/bin/bash # Spotify Conky Now Playing # adapted from the script by Paul Williams if [ ! -f ~/.cache/spotify-nowplaying ] then ~/bin/conky.spotify.nowplaying.sh > ~/.cache/spotify-nowplaying fi if [ ! -f ~/.cache/spotify-paused ] then echo "0" > ~/.cache/spotify-paused fi # Is the same song playing? if [ "$(~/bin/conky.spotify.nowplaying.sh)" != "$(cat ~/.cache/spotify-nowplaying)" ] then ~/bin/conky.spotify.nowplaying.sh > ~/.cache/spotify-nowplaying ~/bin/conky.spotify.nowplaying.length.sh > ~/.cache/spotify-nowplaying-length length=$(cat ~/.cache/spotify-nowplaying-length) secs=$(($length/1000000)) printf ""%d:%02d"\n" $(($secs%3600/60)) $(($secs%60)) > ~/.cache/spotify-nowplaying-length-pretty date +%s > ~/.cache/spotify-nowplaying-starttime # reset paused time. echo "0" > ~/.cache/spotify-paused fi ## is it playing, or paused? status=$(qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get org.mpris.MediaPlayer2.Player PlaybackStatus) if [ "$status" == "Paused" ] then pt=$(cat ~/.cache/spotify-paused) pt=$(($pt+1)) echo "$pt" > ~/.cache/spotify-paused #else #echo "0" > ~/.cache/spotify-paused fi pt=$(cat ~/.cache/spotify-paused) # Work out time elapsed as a percentage of the total time. timethen=$(cat ~/.cache/spotify-nowplaying-starttime) timenow=$(date +%s) # +1 to combat slight delay elapsed=$((($timenow+1)-$timethen-$pt)) printf ""%d:%02d"\n" $(($elapsed%3600/60)) $(($elapsed%60)) > ~/.cache/spotify-nowplaying-elapsed-pretty # Got the elapsed time, now percentage! #totallength=$(cat ~/.cache/spotify-nowplaying-length) #totallengthsecs=$(($totallength / 1000000)) #elapsedper="$elapsed / $totallengthsecs" #elapsedperc=$(echo "scale=2; $elapsedper" | bc ;) #elapsedperce="$elapsedper * 100" #elapsedpercent=$(echo "scale=2; $elapsedperce" | bc ;) #echo $elapsedpercent > ~/.cache/spotify-nowplaying-elapsed chmod 777 ~/.cache/spotify-*
conky.spotify.nowplaying.sh :
#!/bin/bash echo " Artist:" `dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$` echo " Title: " `dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$` echo " Album: " `dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 1 "album"|egrep -v "album"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$`
conky.spotify.nowplaying.length.sh :
#!/bin/bash echo `dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata'|egrep -A 2 "length"|egrep -v "length"|egrep -v "array"|cut -b 43-|cut -d '"' -f 1|egrep -v ^$`
4. Todo.txt
Plain integration from the todo.txt package with regard to configuration and colors. I wrote a small subscript to split up my todo's between work and non-work tasks, and to limit the number shown.
~/.todo/config-conky:
# todo.txt configuration for Conky highlighting. export ORANGE='${color orange}' export BLACK='${color black}' export RED='${color D90000}' export GREEN='${color green}' export BROWN='${color brown}' export BLUE='${color blue}' export PURPLE='${color purple}' export CYAN='${color cyan}' export LIGHT_GREY='${color LightGrey}' export DARK_GREY='${color DarkGrey}' export LIGHT_RED='${color LightRed}' export LIGHT_GREEN='${color LightGreen}' export YELLOW='${color yellow}' export LIGHT_BLUE='${color LightBlue}' export LIGHT_PURPLE='${color LightPurple}' export LIGHT_CYAN='${color LightCyan}' export WHITE='${color white}' export DEFAULT='${color black}' source ~/.todo/config # Adapt this to wherever your todo.txt configuration is located.
conky.todo.pl:
#!/usr/bin/perl my $limit = 6; # shows 5 + N-more line. print '${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Todo Work$font ${color DimGray}${hr 2}'."\n"; my @work = split(/\n/,`todo.sh -d ~/.todo/config-conky ls work | grep -v -P '^--\$|^TODO:\\s'`); my $idx = 0; while ($idx < $limit - 1) { if ($idx == scalar(@work)){ last; } my $line = $work[$idx]; while ($line =~ m/\+\w+/) { $line =~ s/\+\w+//; } $line =~ s/\s+/ /g; print "$line\n"; $idx++ } ## if (scalar(@work) > $limit) { my $diff = scalar(@work) - $limit - 1; print " .. $diff more on full list\n"; } elsif (scalar(@work) == $limit) { my $line = $work[$limit-1]; while ($line =~ m/\+\w+/) { $line =~ s/\+\w+//g; } $line =~ s/\s+/ /g; print "$line\n"; } print '${font Bitstream Vera Sans Mono:size=9:italic}${color D90000}Todo Other$font ${color DimGray}${hr 2}'."\n"; my @work = split(/\n/,`todo.sh -d ~/.todo/config-conky ls | grep -v '+work' | grep -v -P '^--\$|^TODO:\\s'`); my $idx = 0; while ($idx < $limit - 1) { if ($idx == scalar(@work)){ last; } my $line = $work[$idx]; while ($line =~ m/\+\w+/) { $line =~ s/\+\w+//g; } print "$line\n"; $idx++ } ## if (scalar(@work) > $limit) { my $diff = scalar(@work) - $limit - 1; print " .. $diff more on full list\n"; } elsif (scalar(@work) == $limit) { my $line = $work[$limit-1]; while ($line =~ m/\+\w+/) { $line =~ s/\+\w+//g; } print $line; }
5. Monitor for a torque server
the script to run on a webserver with access to the queue:
<?php $running = `qstat -r | wc -l`; $running = $running - 5; $queued = `qstat -i | wc -l`; $queued = $queued - 5; if ($running + $queued < 10) { $all = `qstat -a | tail -n+3 | grep -vP '\sC\s'`; } else { $all = `qstat -a | tail -n+3 | grep -vP '\sC\s' | head -n 9`; $all .= "...".($running+$queued)." in total...\n"; } if ($queued < 0) { $queued = 0; } if ($running < 0) { $running = 0; } echo "Running: $running\n"; echo "Queued : $queued\n"; $lines = explode("\n",$all); array_shift($lines); $lines[0] = str_replace('Job ID', 'JobID',$lines[0]); $idx = 0; foreach ($lines as $key => $line) { if ($line == "") { $idx++; continue; } $cols = preg_split("/\s+/",$line); if ($idx == 1) { echo $cols[3]." ".$cols[6]."\t".$cols[7]."\t"."$cols[9]"." ".$cols[10]."\n"; } else { if (strlen($cols[3]) < 16) { echo $cols[3]."\t ".$cols[6]."\t".$cols[7]."\t"."$cols[9]"." ".$cols[10]."\n"; } else { echo $cols[3]." ".$cols[6]."\t".$cols[7]."\t"."$cols[9]"." ".$cols[10]."\n"; } } $idx++; } ?>
And a script to monitor the status. This is run from the autostart of kde in my case.
#!/bin/bash echo "Starting up..." > ~/.conky_clusterstat.txt echo "." >> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt echo ".">> ~/.conky_clusterstat.txt sleep 60 while [[ 1 ]] ; do curl http://server-url/cluster_stats.php > ~/.conky_clusterstat.txt sleep 60; done
6. Mandatory Screenshot
Cluster, Conky, mpd, spotify, todo.txt, torque/pbs
Comments
I added your spotify pause code to my code, but the timer still keeps going when i pause.
that's strange. I double checked the scripts and all seems to be correct (and working for me).
did you check the existence of all paths (mainly ~/.cache) and permissions ?
LOVE the torque addition to conky! Fantastic idea! Thanks for the code! Cheers from New Orleans, LA!
Thumbs up for both the torque addition and Morphine!
Thanks for the code, cheers from Floripa, Brazil.
Comments
Loading Comments