Pour fonctionner, il nécessite que les fichier ip.sh
et rhythmbox.sh
soient présents dans le dossier ~/.conky
et exécutables. Il ne faut pas oublier d'installer les polices Open Logos et StyleBats.
=> Open Logos | StyleBats
Copie de ip.sh
:
#!/bin/bash # # Test de validité IPv4 de l'adresse entrée (expression régulière) function isIPv4 { if [ $# = 1 ] then printf $1 | grep -Eq '^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-4]|2[0-4][0-9]|[01]?[1-9][0-9]?)$' return $? else return 2 fi } RETOUR=$(wget -qO- whatismyip.org) isIPv4 $RETOUR && echo $RETOUR || echo "Pas de connexion"
Copie du rhythmbox.sh
:
#!/bin/bash case "$1" in progress) curr=`rhythmbox-client --no-start --print-playing-format "%te" | grep -v "Pas de lecture en cours" | grep -v Inconnu` tot=`rhythmbox-client --no-start --print-playing-format "%td" | grep -v "Pas de lecture en cours" | grep -v Inconnu` a=`date +'%S' | sed 's/^0\+//'` if [ "$a" = "" ]; then a=0 fi b=$(( ($a*100) / 30 )) c=$(( 200-$b )) if [ "$curr" = "" ]; then curr=0 fi #si pas de durée totale, augmente pendant les 30 premieres secondes puis diminue pendant les 30 suivantes... if [ "$tot" = "" ]; then if [ $a -le 30 ]; then expr $b else expr $c fi else #Si durée totale déterminée, il faut traiter le retour de la commande donnant $curr (pour courant et $tot pour total, logique) qui renvoit une donnée sous la forme hh:mm:ss d="1" nbcurr=`echo $curr | wc -m` #nbr de caractères permet de déterminer si il y a seulement m:ss ou si il y a h:mm:ss (au minimum, m:ss) posm=$(( $nbcurr-5 )) #pour faire une commande cut générique, il faut définir l'endroit ou on coupe d'ou posx (position des minutes ici) if [ $posm -lt $d ]; then posm=`` #Si position inférieur à 1, renvoit variable vide pour ne pas bloque cut fi posm2=$(( $nbcurr-4 )) #Forcément 1 indication minute (minimum)= pas besoin de vérifier si >1 posh=$(( $nbcurr-8 )) #Idem pour les heures if [ $posh -lt $d ]; then posh=`` fi posh2=$(( $nbcurr-7 )) currs=`echo $curr | tail -c3 | sed 's/^0\+//'` # Récupération des secondes forcément à la fin et supression du premier 0 pour ne pas avoir de problème de base (08 en hexa ou base 10) if [ "$currs" = "" ]; then currs=0 #si uniquement des zeros, ils sont tous supprimé donc redonner la valeur fi currma=`echo $curr | cut -c$posm-$posm2 | sed 's/^0\+//'` if [ "$currma" = "" ]; then currma=0 #idem pour minutes fi currm=$(( $currma*60 )) #conversion en secondes if [ $posh2 -lt $d ]; then currh=0 else currha=`echo $curr | cut -c$posh-$posh2 | sed 's/^0\+//'` if [ "$currha" = "" ]; then #idem heures currha=0 fi currh=$(( $currha*3600 )) # conversion en secondes fi currt=$(( ($currh+$currm) + $currs )) #calcule du nombre de secondes total nbtot=`echo $tot | wc -m` #Même schema pour la suite mais avec la durée totale tposm=$(( $nbtot-5 )) if [ $tposm -lt $d ]; then tposm=`` fi tposm2=$(( $nbtot-4 )) tposh=$(( $nbtot-8 )) if [ $tposh -lt $d ]; then tposh=`` fi tposh2=$(( $nbtot-7 )) tots=`echo $tot | tail -c3 | sed 's/^0\+//'` ## OK if [ "$tots" = "" ]; then tots=0 fi totma=`echo $tot | cut -c$tposm-$tposm2 | sed 's/^0\+//'` ## OK if [ "$totma" = "" ]; then totma=0 fi totm=$(( $totma*60 )) ## OK if [ $tposh2 -lt $d ]; then toth=0 else totha=`echo $tot | cut -c$tposh-$tposh2 | sed 's/^0\+//'` ## OK if [ "$totha" = "" ]; then totha=0 fi toth=$(( $totha*3600 )) ## OK fi tott=$(( ($toth+$totm) + $tots )) ## OK expr $currt \* 100 / $tott #Et finalement expression du pourcentage accompli fi ;; esac
Copie du .conkyrc
:
# set to yes if you want Conky to be forked in the background background yes cpu_avg_samples 2 net_avg_samples 2 out_to_console no # X font when Xft is disabled, you can pick one with program xfontsel #font 7x12 #font 6x10 #font 7x13 #font 8x13 #font 7x12 #font *mintsmild.se* #font -*-*-*-*-*-*-34-*-*-*-*-*-*-* #font -artwiz-snap-normal-r-normal-*-*-100-*-*-p-*-iso8859-1 # Use Xft? use_xft yes # Xft font when Xft is enabled xftfont Bitstream Vera Sans Mono:size=9 own_window_transparent yes own_window_type override own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager own_window_colour hotpink # Text alpha when using Xft xftalpha 0.8 on_bottom yes # mail spool mail_spool $MAIL # Update interval in seconds update_interval 1 # Create own window instead of using desktop (required in nautilus) own_window yes # Use double buffering (reduces flicker, may not work for everyone) double_buffer yes # Minimum size of text area #minimum_size 280 5 #maximum_width 150 # Draw shades? draw_shades yes # Draw outlines? draw_outline no # Draw borders around text draw_borders no # Stippled borders? stippled_borders 10 # border margins border_margin 4 # border width border_width 1 # Default colors and also border colors default_color white default_shade_color black default_outline_color white # Text alignment, other possible values are commented #alignment top_left #minimum_size 10 10 gap_x 13 gap_y 34 alignment top_right #alignment bottom_left #alignment bottom_right # Gap between borders of screen and text # Add spaces to keep things from moving about? This only affects certain objects. use_spacer no # Subtract file system buffers from used memory? no_buffers yes # set to yes if you want all text to be in uppercase uppercase no # boinc (seti) dir # seti_dir /opt/seti # Possible variables to be used: # # Variable Arguments Description # acpiacadapter ACPI ac adapter state. # acpifan ACPI fan state # acpitemp ACPI temperature. # adt746xcpu CPU temperature from therm_adt746x # adt746xfan Fan speed from therm_adt746x # battery (num) Remaining capasity in ACPI or APM # battery. ACPI battery number can be # given as argument (default is BAT0). # buffers Amount of memory buffered # cached Amount of memory cached # color (color) Change drawing color to color # cpu CPU usage in percents # cpubar (height) Bar that shows CPU usage, height is # bar's height in pixels # downspeed net Download speed in kilobytes # downspeedf net Download speed in kilobytes with one # decimal # exec shell command Executes a shell command and displays # the output in torsmo. warning: this # takes a lot more resources than other # variables. I'd recommend coding wanted # behaviour in C and posting a patch :-). # execi interval, shell Same as exec but with specific interval. # command Interval can't be less than # update_interval in configuration. # fs_bar (height), (fs) Bar that shows how much space is used on # a file system. height is the height in # pixels. fs is any file on that file # system. # fs_free (fs) Free space on a file system available # for users. # fs_free_perc (fs) Free percentage of space on a file # system available for users. # fs_size (fs) File system size # fs_used (fs) File system used space # hr (height) Horizontal line, height is the height in # pixels # i2c (dev), type, n I2C sensor from sysfs (Linux 2.6). dev # may be omitted if you have only one I2C # device. type is either in (or vol) # meaning voltage, fan meaning fan or temp # meaning temperature. n is number of the # sensor. See /sys/bus/i2c/devices/ on # your local computer. # kernel Kernel version # loadavg (1), (2), (3) System load average, 1 is for past 1 # minute, 2 for past 5 minutes and 3 for # past 15 minutes. # machine Machine, i686 for example # mails Mail count in mail spool. You can use # program like fetchmail to get mails from # some server using your favourite # protocol. See also new_mails. # mem Amount of memory in use # membar (height) Bar that shows amount of memory in use # memmax Total amount of memory # memperc Percentage of memory in use # new_mails Unread mail count in mail spool. # nodename Hostname # outlinecolor (color) Change outline color # pre_exec shell command Executes a shell command one time before # torsmo displays anything and puts output # as text. # processes Total processes (sleeping and running) # running_processes Running processes (not sleeping), # requires Linux 2.6 # shadecolor (color) Change shading color # stippled_hr (space), Stippled (dashed) horizontal line # (height) # swapbar (height) Bar that shows amount of swap in use # swap Amount of swap in use # swapmax Total amount of swap # swapperc Percentage of swap in use # sysname System name, Linux for example # time (format) Local time, see man strftime to get more # information about format # totaldown net Total download, overflows at 4 GB on # Linux with 32-bit arch and there doesn't # seem to be a way to know how many times # it has already done that before torsmo # has started. # totalup net Total upload, this one too, may overflow # updates Number of updates (for debugging) # upspeed net Upload speed in kilobytes # upspeedf net Upload speed in kilobytes with one # decimal # uptime Uptime # uptime_short Uptime in a shorter format # # seti_prog Seti@home current progress # seti_progbar (height) Seti@home current progress bar # seti_credit Seti@hoome total user credit # variable is given either in format $variable or in ${variable}. Latter # allows characters right after the variable and must be used in network # stuff because of an argument #${font Dungeon:style=Bold:pixelsize=10}I can change the font as well #${font Verdana:size=10}as many times as I choose #${font Perry:size=10}Including UTF-8, #${font Luxi Mono:size=10}justo como este texto que o google traduz fêz o português # stuff after 'TEXT' will be formatted on screen #${font Grunge:size=12}${time %a %b %d}${alignr -25}${time %k:%M} TEXT ${shadecolor black}${font openlogos:size=100}${color 73d216}${alignc}Ut${font}${color}${shadecolor} ${font Arial:size=20}${color 73d216}${alignc}Marvin${color}${font} ${color 73d216}Système ${color}$hr ${font StyleBats:size=10}P${font} Uptime: $uptime ${font StyleBats:size=10}A${font} Processeur : ${cpu}% ${color 73d216}${cpubar}$color ${font StyleBats:size=10}I${font} Mémoire : $memperc% $mem ${color 73d216}${membar}$color ${font StyleBats:size=10}I${font} Swap :$swapperc% ${color 73d216}${swapbar}$color ${font StyleBats:size=10}U${font} Batterie : $battery_percent% $battery_time ${color 73d216}Disque dur ${color}$hr ${font StyleBats:size=10}C${font} Racine : ${fs_used_perc /}% ${fs_free /} ${color 73d216}${fs_bar 5,120 /}$color ${font StyleBats:size=10}C${font} ${if_mounted /home}Home : ${fs_used_perc /home}% ${fs_free /home} ${color 73d216}${fs_bar 5,120 /home}$color ${font StyleBats:size=10}C${font} ${if_mounted /media/donnees}Données : ${fs_used_perc /media/donnees}% ${fs_free /media/donnees} ${color 73d216}${fs_bar 5,120 /media/donnees}$color ${color 73d216}Réseau ${color}$hr ${font StyleBats:size=10}M${font} eth0 : ${addr eth0} ${font StyleBats:size=10}X${font} wlan0 : ${addr wlan0} ${font StyleBats:size=10}B${font} inet0 : ${texeci 120 $HOME/.conky/ip.sh} #${if_running rhythmbox}${color 73d216}Multimédia ${color}$hr #${font StyleBats:size=10}2${font} Artiste : ${exec rhythmbox-client --print-playing-format "%ta"} #${font StyleBats:size=10}J${font} Album : ${exec rhythmbox-client --print-playing-format "%at"} #${font StyleBats:size=10}4${font} Titre : ${exec rhythmbox-client --print-playing-format "%tt"} #${font StyleBats:size=10}7${font} Durée : ${exec rhythmbox-client --print-playing-format "%te"} sur ${exec rhythmbox-client --print-playing-format "%td"} #${color 73d216}${execibar 1 $HOME/.conky/rhythmbox.sh progress}${color}${else} #$endif
Lancement au démarrage
Lancer la commande :
sh -c "sleep 20; conky;"
=> Accueil
Permaliens :
=> gemini://unbon.cafe/yomli/dev/blog/2012-08-06-configuration-de-conky.gmi | https://dev.yom.li/blog/configuration-de-conky This content has been proxied by September (3851b).Proxy Information
text/gemini;