Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How-to: Audacious + conky + imagemagick = desktop audio info + album art

  1. #1
    Join Date
    Aug 2009
    Location
    India
    Beans
    63
    Distro
    Ubuntu 10.04 Lucid Lynx

    How-to: Audacious + conky + imagemagick = desktop audio info + album art

    This how-to explains how to get audio info with conky on your desktop along with album art when playing music via audacious. Check screenshot before you begin any further.
    Even though the shell script is for audacious, the script can be modified for other audio players like rhythmbox and amarok etc...

    The script assumes that each of your music album folder has a file folder.jpg in them.
    The script's biggest feature is that the conky window along with background will only appear when audacious is playing music. Otherwise it will stay invisible.
    Disclaimer:
    1) I originally found a shell script by user eric written for amarok. However I have extended the code extensively, so that calling it via conky becomes easier.

    2) The imagemagick (IM) codes are taken from imagemagick website. The IM code mainly draws the semi-transparent window with rounded corners. A more generic way of making semi-transparent window with rounded corners can be done with the great lua script written by user londonali1010 which can be found here. However if I use this script then the conky window doesn't disappear when audacious is not playing. This is what started me in writing this shell script.

    Requirements:
    Conky (version 1.7.1+), imagemagick, audacious

    Code:
    sudo apt-get install imagemagick conky-all audacious
    Installation:
    STEP - 1:
    Save the script below as audacious-info.sh
    Code:
    #!/bin/bash
    
    ## TODO:
    ## *) Get album art (from web) at each album change (not song change).
    ## *) Draw background at each song change (not every 3secs).
    ## *) Create headphones.jpg or something equivalent via imagemagick 
    ##      on-the-fly
    
    ## Author: Anjishnu Sarkar
    ## Version: 1.0
    ## Acknowledgement(s):
    ## *) The imagemagick code to create round background is from the website
    ##      http://www.imagemagick.org/Usage/thumbnails/#rounded
    
    ## Feature(s):
    ## *) The conky window disappears when audacious is not playing.
    
    ## Info:
    ## *) The script assumes you have an image "folder.jpg" in each of your 
    ##      music albums.
    
    ## Installation:
    ## *********************
    ## chmod +x audacious-info.sh
    ## mkdir -p ~/.conky/shell-scripts/
    ## mkdir -p ~/.conky/pix/
    ## cp audacious-info.sh ~/.conky/shell-scripts/
    
    ## Next create a music.conkyrc. Copy the following relevant conky parts 
    ## in ~/.conky/music.conkyrc
    ## ***************************
    ## minimum_size 325 120
    ## text_buffer_size 2048
    ## imlib_cache_size 0
    ## border_outer_margin 10
    ## TEXT
    ## ${if_running audacious}${execpi 3 ~/.conky/shell-scripts/audacious-info.sh}${endif}
    ## *********************
    
    Corners=10
    Opacity=0.75
    BGColor='grey'  ## '#bebebe'
    # BGColor='#0000ff'
    AlbumArt="folder.jpg"
    BackUpArt="headphones.jpg"
    
    ## Do not change anything after this
    CharLength=7
    StaticWidth=127
    MinWidth=335
    Height=118
    WordCount=0
    
    ListPosition=$(audtool playlist-position)
    Status=$(audtool playback-status)
    EchoStatus="Audacious is $Status"
    
    Title=$(audtool playlist-tuple-data title "$ListPosition")
    if [ -z "$Title" ];then
        Title=$(basename "$(audtool playlist-song-filename \
                "$ListPosition")" .mp3 | sed 's/%20/ /g')
    fi
    TitleCount=$(echo "Title: "$Title"" | wc -m)
    
    Album=$(audtool playlist-tuple-data album "$ListPosition")
    AlbumCount=$(echo "Album: "$Album"" | wc -m)
    
    Artist=$(audtool playlist-tuple-data artist "$ListPosition")
    ArtistCount=$(echo "Artist: "$Artist"" | wc -m)
    
    for varcount in $TitleCount $AlbumCount $ArtistCount 
    do
        if [ $varcount -gt $WordCount ];then
            WordCount=$varcount
        fi
    done
    
    VarWidth=$(echo "${WordCount}*${CharLength}" | bc)
    Width=$(echo ""$StaticWidth"+"$VarWidth"" | bc)
    
    if [ $Width -le $MinWidth ];then
        Width=$MinWidth
    fi
    
    mkdir -p ~/.conky/pix/
    
    DrawBG(){
        convert -size ${Width}x${Height} xc:${BGColor} \
            png:- | convert - \
             \( +clone  -threshold -1 \
                -draw "fill black polygon 0,0 0,"$Corners" "$Corners",0 \
                fill white circle "$Corners","$Corners" "$Corners",0" \
                \( +clone -flip \) -compose Multiply -composite \
                \( +clone -flop \) -compose Multiply -composite \
             \) +matte -compose CopyOpacity -composite  \
            -alpha on -channel RGBA -evaluate multiply ${Opacity} \
             ~/.conky/pix/audbg.png
    }
    
    GetArt(){
        FilePath=$(audtool playlist-tuple-data file-path \
                    "$ListPosition" | sed 's/file:\/\///') 
        if [ -f "$FilePath"/"$AlbumArt" ];then
            cp "$FilePath"/"$AlbumArt" ~/.conky/pix/
        else
            cp ~/.conky/pix/"$BackUpArt" ~/.conky/pix/"$AlbumArt"
        fi
    }
    
    GetProgress(){
        CurrLen=$(audtool current-song-output-length-seconds)
        TotLen=$(audtool current-song-length-seconds)
        if (( $TotLen )); then
            ProgLen=$(expr $CurrLen \* 100  / $TotLen)
        fi
    }
    
    AudaciousInfo(){
        case "$1" in
            bg)         DrawBG ;;
            art)        GetArt ;;
            status)     echo "$EchoStatus" ;;
            title)      echo "$Title" ;;
            artist)     echo "$Artist" ;;
            album)      echo "$Album" ;;
            progress)   GetProgress ;;
        esac
    }
    
    # if 
        AudaciousInfo bg
        AudaciousInfo art
        echo -n "\${image ~/.conky/pix/audbg.png -p 0,0}"
        echo -n "\${image ~/.conky/pix/"$AlbumArt" -p 9,9 -s 100x100}"
        echo ""
        echo -n "                 "
        echo "\${color}$EchoStatus"
        echo ""
        echo -n "                 "
        echo -n "\${color}Title: "
        echo -n "\${color0}"
        AudaciousInfo title
        echo -n "                 "
        echo -n "\${color}Artist: "
        echo -n "\${color0}"
        AudaciousInfo artist
        echo -n "                 "
        echo -n "\${color}Album: "
        echo -n "\${color0}"
        AudaciousInfo album
        AudaciousInfo progress
        echo -n "                 "
        echo "\${execbar echo "$ProgLen"}"
        echo ""
    # fi
    Make the script executable and save it in ~/.conky/shell-scripts
    Code:
    chmod +x audacious-info.sh
    mkdir -p ~/.conky/shell-scripts/
    cp audacious-info.sh ~/.conky/shell-scripts/
    STEP - 2:
    Create a music.conkyrc with the following lines
    Code:
    # Conky sample configuration
    #
    background no
    use_xft yes
    xftfont Bitstream Vera Sans Mono:size=9
    xftalpha 0.8
    mail_spool $MAIL
    update_interval 3.0
    total_run_times 0
    own_window yes
    own_window_type override
    own_window_transparent yes
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    double_buffer yes
    minimum_size 325 120
    draw_shades no
    draw_outline no
    draw_borders no
    draw_graph_borders yes
    stippled_borders 8
    border_width 1
    
    default_color yellow
    color0 white
    color1 green
    color2 red
    default_shade_color grey
    default_outline_color yellow
    
    alignment top_left
    gap_x 140
    gap_y 130
    
    no_buffers yes
    uppercase no
    cpu_avg_samples 2
    net_avg_samples 2
    override_utf8_locale no
    use_spacer none
    text_buffer_size 2048
    imlib_cache_size 0
    
    # border_inner_margin 0
    border_outer_margin 10
    TEXT
    ${if_running audacious}${execpi 3 ~/.conky/shell-scripts/audacious-info.sh}${endif}
    

    I have marked the relevant part of the conkyrc in blue. Save it in the folder ~/.conky/

    STEP - 3:
    Download and save the headphones.jpg in ~/.conky/pix folder. This image is an backup in case you don't have a folder.jpg in your music folders.
    Installation complete.

    Run the script.
    Code:
    conky -c ~/.conky/music.conkyrc
    You won't see anything happening after you run the above command.That's because you haven't played anything with audacious yet. Now start playing some music with audacious. A window will appear on your desktop, like shown in the screenshot, which shows your audio info along with you album art. Isn't that cool.


    Hopefully you will find the script useful.

    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Beans
    21

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    Just stumbled across this. Thanks for posting it. Simple and elegant. Most of the time people get too carried away with the candy and conky (a rabbit hole I have fallen into way too often) it's so fun to play with.

  3. #3
    Join Date
    Aug 2009
    Location
    India
    Beans
    63
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    Dear @statmonkey,
    Thanks for liking it .
    I had updated the script sometime back. Haven't posted it. The updated script should work with any player that supports mpris-remote. This includes amarok, audacious, qmmp, decibel-audio-player etc...

    I will post the updated script and installation in a couple of days.

    You are right - its fun to play with conky.

  4. #4
    Join Date
    Jun 2011
    Location
    Uruguay
    Beans
    2

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    Thanks man, good work!

  5. #5
    Join Date
    Jan 2010
    Beans
    93
    Distro
    Ubuntu

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    great threads

  6. #6
    Join Date
    Dec 2011
    Beans
    1

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    Can I put this in my conky.rc or this is an independant conky?

  7. #7
    Join Date
    Aug 2009
    Location
    India
    Beans
    63
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    @ RiccITA: This is an independent conkyrc

  8. #8
    Join Date
    Aug 2011
    Beans
    32

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    I can get the song description to display, but not the artwork

  9. #9
    Join Date
    Aug 2009
    Location
    India
    Beans
    63
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    @DobsonM

    First covering couple of basic things:

    1. You should have imagemagick installed.
    2. There should be a file called folder.jpg in each of your music folder.

    Now assumming you already had those, run the command
    Code:
    conky -c /path/to/your/music.conkyrc
    in a terminal and then play any song in audacious. What is the output in the terminal?

  10. #10
    Join Date
    Mar 2011
    Beans
    13
    Distro
    Ubuntu 12.04 Precise Pangolin

    Question Re: How-to: Audacious + conky + imagemagick = desktop audio info + album art

    I need your advice on how to correct the issue i have in using your conky.
    you can see the scrot below.
    Thanks.
    Attached Images Attached Images

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •