Conky

Bureaux,conky et autres personnalisations esthétiques.
Répondre
Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Conky

Message par loutch »

Bonjour

Pour ceux qui écoutent la radio avec radiotray un conky avec affichage de la pochette du titre joué .

Le conkyrc :

Code : Tout sélectionner

background yes
use_xft yes
xftfont URW Chancery L:style=Bold:size=10
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
#own_window_color 000000
own_window_argb_visual yes
#own_window_argb_value 0
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 250 300
maximum_width 250
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_outline_color white
alignment top_right
gap_x 0
gap_y 580
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
imlib_cache_flush_interval 60
imlib_cache_size 500


# Taille des pointillés
stippled_borders 5

# Couleurs
default_color FFFFFF #blanc
default_shade_color 333333
default_outline_color black


lua_load ~/.conky/lua/image.lua

TEXT

${voffset -25}${font URW Chancery L:style=Bold:size=20}${alignc}Radiotray ${font}
Radio : ${alignc}${font URW Chancery L:style=Bold:size=12}${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray net.sourceforge.radiotray.getCurrentRadio}$font
${alignc}${voffset 50}En ce moment :
${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w40 }
${execi 10 qdbus net.sourceforge.radiotray /net/sourceforge/radiotray getCurrentMetaData| fold -s -w40 > ~/.conky/radiotray/artiste_titre.txt}
${texeci 20 ~/.conky/radiotray/image.sh}
${lua fDrawImage ~/.conky/radiotray/image.png 50 150 150 150 }
le script "image.sh":

Code : Tout sélectionner

#!/bin/bash
# créer par loutch et WW

titre=$(head --lines=1 ~/.conky/radiotray/artiste_titre.txt)
# Ajout d'un compteur si jamais tu veux faire défiler plusieurs images
count=1

imageLink=$(wget --user-agent 'Firefox/38.0' -qO - "https://www.google.fr/search?q=${titre}\&tbm=isch" |\
sed 's/</\n</g' | grep "a href=\"http://www.google.fr/imgres?imgurl=" | head --lines=${count} |\
sed 's!.*http://www.google.fr/imgres?imgurl=\([^&]*\).*!\1!')
wget --output-document="googleImage".jpg $imageLink



convert ~/googleImage.jpg ~/.conky/radiotray/image.png

exit
En image:
Image

@+
Modifié en dernier par zeb le mer. 29 avr. 2020 14:47, modifié 2 fois.
Raison : image mise sur FFLMpics
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Bonjour

Pour chaque conky que j'utilise et dès qu'il faut afficher une image ou une icône j'utilise un script lua qui est placé dans son dossier à part, comme cela j'ai toujours la même ligne pour l'appeler soit :

lua_load ~/.conky/lua/image.lua

Mise avant la partie TEXT des conkys .Cela permet d'avoir toutes les images (obligatoirement une png) qui restent voyantes quel que soit le type de fond d'écran clair ou foncé.

Puis dans le conky j'appelle l'image ainsi:

${lua fDrawImage ~/.conky/radiotray/image.png 50 100 150 150 0 }


${lua fDrawImage= fonction lua
~/.conky/...= chemin de l'image @ afficher
50=position horizontale en partant de gauche
100=position verticale en partant du haut
150=hauteur de l'image
150=largeur de l'image
0=rotation de l'image (on peut ici ne rien mettre sinon 0.1 -1-1.5 ou autre jusqu'à la rotation désirée.

le script :

Code : Tout sélectionner

--créer par  Didier-T




require 'cairo'
home = os.getenv ('HOME')

--Fonction d'affichage
function conky_fDrawImage(path,x,y,w,h,arc)

	path = string.gsub(path, "~", home)
	path = string.gsub(path, "$HOME", home)

	local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
	
	local function fDrawImage(path,x,y,w,h,arc)
		x=x+(w/2)
		y=y+(h/2)
		local img =  cairo_image_surface_create_from_png(path)
		local w_img, h_img = cairo_image_surface_get_width (img), cairo_image_surface_get_height (img)

		local cr = cairo_create (cs)
		cairo_translate (cr, x, y)

		if arc then
			cairo_rotate (cr, arc)
		end

		cairo_scale (cr, w/w_img, h/h_img)
		cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
		cairo_paint (cr)
		cairo_destroy(cr)
		cairo_surface_destroy (img)
	end
	fDrawImage(path,x,y,w,h,arc)
	cairo_surface_destroy(cs)
	return ""
end
@+
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Hello

Pour audacious :

le conkyrc :

Code : Tout sélectionner

background yes
use_xft yes
xftfont URW Chancery L:style=Bold:size=10
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 310 500
maximum_width 310
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color ffffff
default_outline_color black
alignment tr
gap_x 0
gap_y 400
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
# Fonctionne uniquement avec les polices Fixes
#use_spacer yes
imlib_cache_size 0 
 uppercase no

  
 lua_load ~/.conky/lua/image.lua


TEXT

${font URW Chancery L:style=Bold:size=20}${alignc}Audacious ${font}
${exec ~/.conky/audacious/cover.sh}
${lua fDrawImage ~/.conky/audacious/audacious.png 60 255 180 180 0}
Audacious is ${execi 3 audtool playback-status} ${stippled_hr}
Titre    ${goto 50}: ${goto 100} ${execi 3 audtool current-song-tuple-data title}
Artiste  ${goto 50}: ${goto 100} ${execi 3 audtool current-song-tuple-data artist}
Album    ${goto 50}: ${goto 100} ${execi 3 audtool current-song-tuple-data album}
Année    ${goto 50}: ${goto 100} ${execi 3 audtool current-song-tuple-data year}
Position ${goto 50}: ${goto 100} ${execi 3 audtool playlist-position} of ${execi 10 audtool playlist-length}
Bitrate  ${goto 50}: ${goto 100} ${execi 3 audtool --current-song-bitrate-kbps} kbps  
Durée    ${goto 50}: ${goto 100} ${execi 0.5 audtool current-song-output-length}  ${goto 290}${execi 3 audtool current-song-length}
                     ${goto 100} ${execbar expr 100 \* $(audtool --current-song-output-length-seconds) \/ $(audtool --current-song-length-seconds)}
          

le cover.sh:

Code : Tout sélectionner

 
#!/bin/bash
# créer par Loutch

cp /tmp/audacious-temp* ~/.conky/audacious/audacious.jpg 

convert ~/.conky/audacious/audacious.jpg ~/.conky/audacious/audacious.png

exit
Image
@+
Modifié en dernier par zeb le mer. 29 avr. 2020 14:48, modifié 1 fois.
Raison : image mise sur FFLMpics
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Bonjour

Pour ceux que cela intéresse voici un lanceur pour l'utilisation d'un programme et de son conky .

Pour l'exemple j'ai pris le lecteur Audacious et son conky.

Voici le script @ rendre éxécutable mis dans votre Home :

Code : Tout sélectionner

 
#!/bin/bash

PROG_NAME1="conky -c /home/$USER/.conky/audacious/conkyrc"	# Nom du programme à  démarrer/arrêter.
PROG_NAME2="/usr/bin/audacious" # Nom du programme à  démarrer/arrêter.

PROCESSPID1=$(pgrep -f /home/$USER/.conky/audacious/conkyrc)	# Récupère le PID du processus.
PROCESSPID2=$(pgrep -f "usr/bin/audacious")	# Récupére le PID du processus.


if [[ "$PROCESSPID1" != ""  && "$PROCESSPID2" != "" ]]; then	# Si les deux processus existe alors on le(s) kill.
        kill $PROCESSPID1 && echo "Stop $PROG_NAME1 (PID: $PROCESSPID1)"
        kill $PROCESSPID2  && echo "Stop $PROG_NAME2 (PID: $PROCESSPID2)"
else	# Si aucun processus on démarre le programme.
        kill $PROCESSPID1 
        $PROG_NAME1 & 
        echo "Start $PROG_NAME1"
        kill $PROCESSPID2  
        $PROG_NAME2 & 
        echo "Start $PROG_NAME2"
        if [[ "$PROCESSPID1" == ""  || "$PROCESSPID2" == "" ]]; then	# Si un des processus n'existe pas alors on le(s) kill.
                kill $PROCESSPID1 && echo "Stop $PROG_NAME1 (PID: $PROCESSPID1)"
                kill $PROCESSPID2  && echo "Stop $PROG_NAME2 (PID: $PROCESSPID2)"
                echo "Il y a eu un souci au lancement tout a été coupé"
        fi
fi

exit 0
Ensuite on édite son menu pour y rajouter ce script avec une belle icône et on l'ajoute à son tableau de bord ou sa barre des tâches ou son bureau .
Un clic pour ouvrir et un reclic pour refermer le programme et son conky ,comme cela il ni à plus de conky ouvert et non actif.



@+
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Bonjour

Pour ne pas laisser en plan ceux qui utilisent Amarok:

le conkyrc:

Code : Tout sélectionner

background yes
use_xft yes
xftfont URW Chancery L:style=bold:size=12
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
#own_window_color 000000
own_window_argb_visual yes
#own_window_argb_value 0
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 300 400
maximum_width 300
text_buffer_size 1024
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders yes
default_color white
default_outline_color white
alignment top_right
gap_x 50
gap_y 400
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
# Fonctionne uniquement avec les polices Fixes
#use_spacer yes

# Taille des pointillés
stippled_borders 5

# Couleurs
default_color FFFFFF #blanc
default_shade_color 333333
default_outline_color black
imlib_cache_size 0 

color1 white
#
color2 e8e8e8
#
color3 6495ee
#
color4 cacaca
#
color5 e7e7e7
#
color6 red

lua_load ~/.conky/lua/image.lua

TEXT

${if_running amarok}Amarok: ${voffset 3}${stippled_hr 1}
${execi 10 ~/.conky/amarok/getcover.sh}
${execi 10 ~/.conky/amarok/Amarok artist}
${execi 10 ~/.conky/amarok/Amarok title}
${execi 10 ~/.conky/amarok/Amarok year}
${execi 1 ~/.conky/amarok/Amarok time}
${execibar 1 ~/.conky/amarok/Amarok progress}
${lua fDrawImage ~/.conky/cover.png 70 180 150 150 0}
$endif

le script "Amarok"

Code : Tout sélectionner

 
#!/bin/bash                     
#fetch conky amarok2 information
#by Mjheagle8                   
#requires: amarok >= 2.0, qdbus 
#[ $(pgrep amarok) ] || exit  #This just tests whether amarok is running and exits if it's not.

case "$1" in
    version)
        qdbus org.kde.amarok / Identity   # There's no point in using an echo here when the qdbus command will spit out the information itself.
        ;;                                # Also, with qdbus, it's not necessary to call the full method interface. Just 'Identity' here suffices.
    artist)                                                                                                                                       
        qdbus org.kde.amarok /Player GetMetadata | grep ^artist:                                                                      
        ;;                                # When you're using the cut command, it's not necessary to supply an ending position if you just want to cut to the end.
                                         title)                                                                                                                                                        
        qdbus org.kde.amarok /Player GetMetadata | grep title:                                                                                        
        ;;                                                                                                                                                        
    album)                                                                                                                                                        
        qdbus org.kde.amarok /Player GetMetadata | grep album: 
        ;;
    year)
        qdbus org.kde.amarok /Player GetMetadata | grep year:
        ;;
    genre)
        qdbus org.kde.amarok /Player GetMetadata | grep genre: 
        ;;
    bitrate)
        echo `qdbus org.kde.amarok /Player GetMetadata | grep audio-bitrate: | cut -c 16-`' Kb/s'
        ;;
    rating)
        qdbus org.kde.amarok /Player GetMetadata | grep rating:
        ;;
    type)
        type=`qdbus org.kde.amarok /Player GetMetadata | grep location:`
        echo ${type:(-3)}                  # Here we're using bash string manipulation to pick off the last three characters.
        ;;
    time)
        pos=$((`qdbus org.kde.amarok /Player PositionGet`/1000)) # Here we divide by 1000 without using an intermediate variable.
    time=$((`qdbus org.kde.amarok /Player GetMetadata | grep mtime: | cut -c 8-`/1000))
    currm=$((pos/60))
    currs=$((pos%60))
    totm=$((time/60))
    tots=$((time%60))
    if [ $((currm/60)) -lt 10 ]; then
        currm=`~/.conky/conversion.sh $currm`
    fi
    if [ $((currs%60)) -lt 10 ]; then
        currs=`~/.conky/conversion.sh $currs`
    fi
    if [ $((totm/60)) -lt 10 ]; then
        totm=`~/.conky/conversion.sh $totm`
    fi
    if [ $((tots%60)) -lt 10 ]; then
        tots=`~/.conky/conversion.sh $tots`
    fi
    echo $currm:$currs / $totm:$tots
    ;;
    timeperc)
        pos=$((`qdbus org.kde.amarok /Player PositionGet`/10))
        time=$(`qdbus org.kde.amarok /Player GetMetadata | grep mtime: | cut -c 8-`/1000)
        echo $((pos/time))
        ;;
    progress)
    pos=$((`qdbus org.kde.amarok /Player PositionGet`/1000)) # Here we divide by 1000 without using an intermediate variable.
    time=$((`qdbus org.kde.amarok /Player GetMetadata | grep mtime: | cut -c 8-`/1000))
    currm=$((pos/60))
    currs=$((pos%60))
    totm=$((time/60))
    tots=$((time%60))
    if [ $((currm/60)) -lt 10 ]; then
        currm=`~/.conky/conversion.sh $currm`
    fi
    if [ $((currs%60)) -lt 10 ]; then
        currs=`~/.conky/conversion.sh $currs`
    fi
    if [ $((totm/60)) -lt 10 ]; then
        totm=`~/.conky/conversion.sh $totm`
    fi
    if [ $((tots%60)) -lt 10 ]; then
        tots=`~/.conky/conversion.sh $tots`
    fi
    curr=$currm:$currs
    tot=$totm:$tots
    a=`date +'%S' | sed 's/^0\+//'`
    if [ "$a" = "" ]; then
        a=0
    fi
        b=$(( ($a*100) / 30 ))
     c=$(( 200-$b ))
    #si pas de durée totale, augmente pendant les 30 premieres secondes puis diminu pendant les 30 suivantes...
       if [ "$tot" = "" ]; then 
        if [ $a -le 30 ]; then
            expr $b
            else
            expr
        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é 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
le script "getcover.sh":

Code : Tout sélectionner

#!/bin/bash
# get Amarok cover art  of current track and transform into an album stack
# copypasta from  http://www.imagemagick.org/Usage/thumbnails/#polaroid
# thanks to  eightmillion for completely rewriting the script
# http://ubuntuforums.org/showpost.php?p=8117609&postcount=9846

# edited by fireandfuel                   
# requires: amarok >= 2.0, dbus, libqt4-dbus, perl

# Temp directory must be full path.
tempdir="$HOME/.conky/"
tempfile="${tempdir}nowplaying"

[ -d "$tempdir" ] || mkdir -p "$tempdir"  #test if $tempdir exists, if  not create it.
[ -e "$tempfile" ] || touch "$tempfile"

cover="$(qdbus org.kde.amarok /Player GetMetadata | grep arturl: | cut -c 16- | perl -MURI::Escape -lne 'print uri_unescape($_)')"
if  [[ -z "$cover" ]]; then #test if $cover was set, if not copy nocover.png to cover.png .

    hash=0

     read oldhash < "$tempfile"

    cover="${tempdir}nocover.png"

     if [ "$oldhash" == "$hash" ];then
        :
    else
         cp "${cover}" "${tempdir}cover.png"

        echo 0 >  "$tempfile"
    fi
else

    hash=$(echo "$cover" | md5sum |  cut -d" " -f 1) #Generate hash for current song.

    read  oldhash < "$tempfile"

    if [ "$oldhash" == "$hash" ];then
             :
    else
        convert "${cover}" -resize 200x200  "${tempdir}cover.png"
    
            echo $hash > "$tempfile"
     fi
    
fi
exit
Image


@+
Modifié en dernier par zeb le mer. 29 avr. 2020 14:50, modifié 1 fois.
Raison : image mise sur FFLMpics
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Bonjour

Une petite partie "exaile" pour ceux qui utilisent ce lecteur, à ajouter à un conky existant. On peut aussi comme moi en faire un spécial pour ce lecteur.
La partie après TEXT (ce qui est entre /home et les /exaile_conky.py )sera à modifier en fonction de votre emplacement. La pochette c'est exaile qui l'affiche sur le bureau grâce à un greffon.

Code : Tout sélectionner

${if_running exaile}
${exec  /home/romuald/.conky/exaile/exaile_conky.py ART}
${exec  /home/romuald/.conky/exaile/exaile_conky.py ALB}
${exec  /home/romuald/.conky/exaile/exaile_conky.py TTL}
${execbar  /home/romuald/.conky/exaile/exaile_conky.py PROG} #size bar - see > default_bar_size

${exec  /home/romuald/.conky/exaile/exaile_conky.py POS} mn  sur ${exec  /home/romuald/.conky/exaile/exaile_conky.py LNG} : ${exec  /home/romuald/.conky/exaile/exaile_conky.py PROG} % ${endif}
le exaile_conky.py

Code : Tout sélectionner

#!/usr/bin/env python
 
import sys, dbus
import Image
from StringIO import StringIO

try:
    datar = sys.argv[1]
except:
    print "script parameter missing"
    sys.exit()
bus = dbus.SessionBus()
try:

    remote_object = bus.get_object("org.exaile.Exaile","/org/exaile/Exaile")
    iface = dbus.Interface(remote_object, "org.exaile.Exaile")
    if iface.IsPlaying():

        if datar == "POS": #Current position sec
            output = iface.CurrentPosition()
            print  output
        
        if  datar == "PROG": #play progress in percent
            output = iface.CurrentProgress()
            print  output
        
        if  datar == "STA": #status play/pause
            output = iface.GetState()
            if output == "playing": #blinking play button
               put = iface.CurrentPosition()
               put = put.replace(':', '')
               if (not int(put)%2 ):
          print "V"
               else: 
                    print  "X"

         
            elif output == "paused":
               print "Z"
            else:
              print "I"

        
        if  datar == "VOL": #volume
            output = iface.GetVolume()
            output = output.split('.')
            output = output[0]
            print output
        

        if  datar == "TTL": #title song
            output = iface.GetTrackAttr("title")
            print  output.encode('utf8')
        
        if  datar == "ALB": #album
            output = iface.GetTrackAttr("album")
            print  output.encode('utf8')
        
        if  datar == "ART": #artist
            output = iface.GetTrackAttr("artist")
            print  output.encode('utf8')
        
        if  datar == "LNG": #combo information about lenght\progress\full lenght
            output1 = float(iface.GetTrackAttr('__length'))
            output = '%d:%02d' % (output1 // 60, output1 % 60)
            print  output

        if  datar == "TIK": #play progress in percent
            output = iface.CurrentPosition()
            output = output.replace(':', '')
            if (not int(output)%2 ):
      print "G"
            else: 
                print  ""


#            dbusArray = iface.GetCoverData()
#            coverdata = "".join(chr(byte) for byte in dbusArray)
#            if coverdata:
#                im = Image.open(StringIO(coverdata))
#                im.show()


    else:
            print "q"
except dbus.exceptions.DBusException:
        print "I"
Image
@+
Modifié en dernier par zeb le mer. 29 avr. 2020 14:53, modifié 1 fois.
Raison : image mise sur FFLMpics
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Bonjour

Conky pour internet ethernet et wifi

eno1 sera à remplacer par eth0 ou autre
wlp2s0 sera à remplacer par wlan0 ou autre.

conkyrc:

Code : Tout sélectionner

 
background no
use_xft yes
xftfont URW Chancery L:style=Bold:size=10
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 300 210
maximum_width 300
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color ffffff
default_outline_color white
alignment top_right
gap_x 30
gap_y 160
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
default_color ffffff
ks

TEXT

${if_existing /sys/class/net/eno1/operstate up}ENO1  ${alignr}${color2}${addr eno1}
DOWN  ${alignr}${downspeed eno1} k/s
UP    ${alignr}${upspeed eno1} k/s
TOTAL ${goto 85}${totaldown eno1} ${goto 170}TOTAL ${alignr}${totalup eno1}
${downspeedgraph eno1 10,125} ${alignr}${upspeedgraph eno1 10,125}
${else}
${if_existing /sys/class/net/wlp2s0/operstate up}WIFI  ${goto 100}wlp2s0  ${goto 170}IP ${alignr}${addr wlp2s0} 
SSID  ${goto 67}${color2}${wireless_essid wlp2s0} ${goto 170}BITRATE ${alignr}${wireless_bitrate wlp2s0}
DOWN  ${goto 80}${downspeed wlp2s0} k/s           ${goto 170}UP ${color2}${alignr}${upspeed wlan0}k/s
TOTAL ${goto 90}${totaldown wlp2s0}               ${goto 170}TOTAL ${alignr}${totalup wlp2s0}
${downspeedgraph wlp2s0 10,130} ${alignr}${upspeedgraph wlp2s0 10,130}
${endif}${endif}
Image
@+
Modifié en dernier par zeb le mer. 29 avr. 2020 14:54, modifié 1 fois.
Raison : image mise sur FFLMpics
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Hello

Conky avec l'image du jour du site de la nasa.

le conkyrc:

Code : Tout sélectionner

background no
use_xft yes
xftfont URW Chancery L:style=Bold:size=11
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 360 210
maximum_width 360
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color ffffff
default_outline_color white
alignment top_right
gap_x 30
gap_y 360
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
###############################
#   1h=60m=3600s              #
#   1j=24h=1440m=86400s       #
#365j=8760h=525600m=31536000s #
###############################


default_color ececec
color2 585858
color1 606060

lua_load ~/.conky/nasa/image.lua

TEXT
${texeci 28800 ~/.conky/nasa/nasa-day.sh} 
${lua conky_fDrawImage /tmp/image_nasa.png 0 0 350 200}

image.lua:

Code : Tout sélectionner

 
require 'cairo'
home = os.getenv ('HOME')

--Fonction d'affichage
function conky_fDrawImage(path,x,y,w,h,arc)

	path = string.gsub(path, "~", home)
	path = string.gsub(path, "$HOME", home)

	local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
	
	local function fDrawImage(path,x,y,w,h,arc)
		x=x+(w/2)
		y=y+(h/2)
		local img =  cairo_image_surface_create_from_png(path)
		local w_img, h_img = cairo_image_surface_get_width (img), cairo_image_surface_get_height (img)

		local cr = cairo_create (cs)
		cairo_translate (cr, x, y)

		if arc then
			cairo_rotate (cr, arc)
		end

		cairo_scale (cr, w/w_img, h/h_img)
		cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
		cairo_paint (cr)
		cairo_destroy(cr)
		cairo_surface_destroy (img)
	end
	fDrawImage(path,x,y,w,h,arc)
	cairo_surface_destroy(cs)
	return ""
end
le nasa-day.sh:

Code : Tout sélectionner

#!/bin/bash
#ragamatrix'script modified#
IMG="/tmp/image_nasa.jpg"
IMGPNG="/tmp/image_nasa.png"

test=`curl -s http://www.nasa.gov/rss/dyn/image_of_the_day.rss | grep -m1 "<enclosure" | sed 's/^.*url="//' | sed 's/" len.*$//'` && wget -O $IMG $test
convert $IMG -resize 640x360 $IMGPNG

convert  $IMGPNG \
\( +clone  -alpha extract \
       -draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
        \( +clone -flip \) -compose Multiply -composite \
        \( +clone -flop \) -compose Multiply -composite \
     \) -alpha off -compose CopyOpacity -composite $IMGPNG
     
convert $IMGPNG  -background  black  \( +clone -shadow 60x4+2+2 \) +swap -background  none   -flatten $IMGPNG
Fichiers joints
nasa.png
nasa.png (162.05 Kio) Vu 6296 fois
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Bonjour

une météo toute simple, il faut "xsltproc"
c'est du site ubuntu.fr et j'ai enlevé tous les caractères spéciaux et mis en bon français.
La police est ici:
http://download.ubuntu-fr-secours.org/c ... er.tar.bz2

et il faudra modifier le code pour votre ville frxx...... en allant ici:
http://www.weather.com/ vous tapez le nom de votre ville et le code apparaitra dans l'adresse de la barre de recherche genre FRXX0064



le conkyrc:

Code : Tout sélectionner

 
background yes
use_xft yes
xftfont URW Chancery L:style=Bold:size=10
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
#own_window_color 000000
own_window_argb_visual yes
#own_window_argb_value 0
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 270
maximum_width 270
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_outline_color white
alignment top_left
gap_x 0
gap_y 680
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
# Fonctionne uniquement avec les polices Fixes
#use_spacer yes

 uppercase no 
 
 
 TEXT
 
${execi 120 ~/.conky/meteo/meteo.sh USFL0543}${alignc}${font URW Chancery L:style=Medium Italic:pixelsize=18}${execi 120 ~/.conky/meteo/meteo2.sh "Ville"}  ${font}

Aujourd'hui :       ${goto 100}${execi 120 ~/.conky/meteo/meteo2.sh "Température aujourd'hui"}  
Vent :              ${goto 100}${execi 120 ~/.conky/meteo/meteo2.sh "Vent aujourd'hui"}
Lever du soleil :   ${goto 100}${execi 120 ~/.conky/meteo/meteo2.sh "Lever du soleil"}
Coucher du soleil : ${goto 100}${execi 120 ~/.conky/meteo/meteo2.sh "Coucher du soleil"}
Demain :            ${goto 100}${execi 120 ~/.conky/meteo/meteo2.sh "Température demain"}
${font weather:size=40}${voffset -100}${goto 210}${execi 120 ~/.conky/meteo/meteo2.sh "Conditions aujourd'hui"}
${font weather:size=40}${voffset 10}  ${goto 210}${execi 120 ~/.conky/meteo/meteo2.sh "Conditions demain"}

meteo.sh:

Code : Tout sélectionner

 
#!/bin/bash

# Répertoire de ce script et du XSLT
RUNDIR=~/.conky/meteo
# Emplacement du XSLT
XSLT=$RUNDIR/meteo.xslt
# Fichier de destination des informations
DESTFILE=/tmp/conky_meteo.txt
# Emplacement de xsltproc
XSLTCMD=/usr/bin/xsltproc

# Traitement
URL="http://xml.weather.com/weather/local/$1?cc=*&unit=m&dayf=2"
w3m -dump $URL | $XSLTCMD $XSLT - > $DESTFILE
meteo2.sh:

Code : Tout sélectionner

 
#!/bin/bash

# Fichier où sont stockées les informations
SRCFILE=/tmp/conky_meteo.txt

# Traitement
RESULTAT=$(grep "$1" $SRCFILE | awk -F " : " '{print $2}')

# Transformation de la condition en lettre qui deviendra une icône
if echo "$1" | grep -i -q 'condition'; then
	  if echo "$RESULTAT" | grep -i -q 'partly cloudy'; then
		RESULTAT='c'
	elif echo "$RESULTAT" | grep -i -q 'fair'; then
		RESULTAT='b'
	elif echo "$RESULTAT" | grep -i -q 'sunny'; then
		RESULTAT='D'
	elif echo "$RESULTAT" | grep -i -q 'cloudy'; then
		RESULTAT='d'
	elif echo "$RESULTAT" | grep -E -i -q 'storm|thunder'; then
		RESULTAT='i'
	elif echo "$RESULTAT" | grep -i -q 'snow'; then
		RESULTAT='k'
	elif echo "$RESULTAT" | grep -i -q 'rain'; then
		RESULTAT='h'
	elif echo "$RESULTAT" | grep -i -q 'shower'; then
		RESULTAT='g'
	fi

# Transformation des heures à  l'américaine (5:50 AM) en heures à la française (5h50)
elif echo "$1" | grep -i -q 'soleil'; then
	RESULTAT=$(echo "$RESULTAT" | awk '{print $1}' | sed -e s/:/h/g)

	# Transformation des heures PM (9h38 PM) en heures françaises (21h38)
	if echo "$1" | grep -i -q 'coucher'; then
		HEURES=$(echo "$RESULTAT" | awk -F "h" '{print $1}')
		MINUTES=$(echo "$RESULTAT" | awk -F "h" '{print $2}')
		HEURES=$(($HEURES + 12))
		RESULTAT="${HEURES}h${MINUTES}"
	fi

# Transformation de "Ville, Pays" en "Ville"
elif echo "$1" | grep -i -q 'ville'; then
	RESULTAT=$(echo "$RESULTAT" | awk -F "," '{print $1}')

fi

# Affichage du résultat
echo $RESULTAT
meteo.xslt:

Code : Tout sélectionner

 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
        <xsl:output method="text" disable-output-escaping="yes"/>
        <xsl:template match="weather">
        	<xsl:text>Ville : </xsl:text><xsl:value-of select="/weather/loc/dnam"/>
                <xsl:apply-templates select="cc"/>
                <xsl:apply-templates select="dayf/day[@d='1']"/>
                <xsl:text>
Lever du soleil : </xsl:text><xsl:value-of select="/weather/loc/sunr"/>
		<xsl:text>
Coucher du soleil : </xsl:text><xsl:value-of select="/weather/loc/suns"/>
        </xsl:template>

        <xsl:template match="cc">
<xsl:text>
Température aujourd'hui : </xsl:text><xsl:value-of select="tmp"/> °<xsl:value-of select="/weather/head/ut"/>
<xsl:if test="tmp != flik">
<xsl:text> (</xsl:text>
<xsl:value-of select="flik"/> °<xsl:value-of select="/weather/head/ut"/>
<xsl:text> ressenti)</xsl:text>
</xsl:if>
<xsl:text>
Conditions aujourd'hui : </xsl:text><xsl:value-of select="t"/>
<xsl:text>
Vent aujourd'hui : </xsl:text>
<xsl:choose>
<xsl:when test="wind/s = 'calm'"><xsl:text>0</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="wind/s"/></xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="/weather/head/us"/>
</xsl:template>

<xsl:template match="dayf/day[@d='1']">
<xsl:text>
Température demain : de </xsl:text><xsl:value-of select="low"/> °<xsl:value-of select="/weather/head/ut"/>
<xsl:text> à  </xsl:text><xsl:value-of select="hi"/> °<xsl:value-of select="/weather/head/ut"/>
<xsl:text>
Conditions demain : </xsl:text><xsl:value-of select="part[@p='d']/t"/>
</xsl:template>
</xsl:stylesheet>

@+
Fichiers joints
meteo4.png
meteo4.png (49.97 Kio) Vu 6277 fois
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Avatar du membre
loutch
Messages : 517
Enregistré le : lun. 13 juil. 2015 17:32
Localisation : Sarreguemines

Re: Conky

Message par loutch »

Hello

Un tout simple:

Code : Tout sélectionner


background yes
use_xft yes
xftfont URW Chancery L:style=Bold:size=10
xftalpha 1
update_interval 1.0
total_run_times 0
own_window yes
own_window_transparent yes
own_window_argb_visual yes
own_window_type normal
own_window_hints undecorated,below,skip_taskbar,skip_pager
double_buffer yes
minimum_size 700 50
maximum_width 700
text_buffer_size 2048
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color ffffff
default_outline_color black
alignment top_left
gap_x 50
gap_y 780
no_buffers yes
uppercase no
cpu_avg_samples 2
override_utf8_locale yes
# Fonctionne uniquement avec les polices Fixes
#use_spacer yes
imlib_cache_size 0 
 uppercase no



TEXT

${voffset 20}${color EAEAEA}${font GE Inspira:pixelsize=120}${time %H:%M}${font}${voffset -84}${offset 10}${color FFA300}${font GE Inspira:pixelsize=42}${time %d} ${voffset -15}${color EAEAEA}${font GE Inspira:pixelsize=22}${time  %B} ${time %Y}${font}${voffset 24}${font GE Inspira:pixelsize=58}${offset -148}${time %A}${font}
${voffset 10}${offset 12}${font Ubuntu:pixelsize=12}${color FFA300}HD ${offset 9}$color${fs_free /} / ${fs_size /}${offset 30}${color FFA300}RAM ${offset 9}$color$mem / $memmax${offset 30}${color FFA300}CPU ${offset 9}$color${cpu cpu0}%
${voffset 70}
Image
@+
Modifié en dernier par zeb le mer. 29 avr. 2020 14:55, modifié 1 fois.
Raison : image mise sur FFLMpics
HP Pavilion g 7 1357 sf avec ssd Tessa cinnamon Mageia 7rc mate
Asus ROG avec xubuntu 18.04 et xubuntu 19.04

Image

Répondre