aboutsummaryrefslogtreecommitdiffstats
path: root/.config/cmus/cc1.sh
blob: 759e802f167a534f6e470589a7a8dcdcaf3ffb4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
FOLDER=$( cmus-remote -Q | grep "file" | sed "s/file //" | rev | cut -d"/" -f2- | rev )

FLIST=$( find "$FOLDER" -type f )

if echo "$FLIST" | grep -i ".jpeg\|.png\|.jpg" &>/dev/null; then
    ART=$( echo "$FLIST" | grep -i "cover.jpg\|cover.png\|front.jpg\|front.png\|folder.jpg\|folder.png" | head -n1 )
    
    if [[ -z "$ART" ]]; then
        ART=$( echo "$FLIST" | grep -i ".png\|.jpg\|.jpeg" | head -n1 )
    fi
    
    PROC=$( ps -eF | grep "feh" | grep -v "cmus\|grep" | cut -d"/"  -f2- )
    
    if [[ "/$PROC" == "$ART" ]]; then
        exit
    fi
    
    killall -q feh
    
    # '200x200' is the window size for the artwork. '+1160+546' is the offset.
    # For example, if you want a 250 by 250 window on the bottom right hand corner of a 1920 by 1080 screen: "250x250+1670+830"
    setsid feh --bg-color black -g 250x250+1670+830 -x --fill "$ART" &
else
    killall -q feh
    exit
fi