-
Notifications
You must be signed in to change notification settings - Fork 0
/
mnuc
executable file
·35 lines (28 loc) · 1.03 KB
/
mnuc
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
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Script intended to be executed from ncmpcpp (execute_on_song_change
# preference) running from urxvt to set album cover as background image
# Copyright (c) 2013 Vyacheslav Levit
# Licensed under The MIT License: http://opensource.org/licenses/MIT
MUSIC_DIR=$MUSIC/library
# tmp_cover=/tmp/cover.jpg
#IM_ARGS=(-limit memory 32mb -limit map 64mb)
reset_background() {
printf "\e]20;;100x100+1000+1000\a"
}
{
file="$(mpc --format %file% current)"
album_dir="${file%/*}"
[[ -z "$album_dir" ]] && { reset_background ; exit 1 ; }
album_dir="$MUSIC_DIR/$album_dir"
cover=$(find "$album_dir" -regex "$album_dir/cover.[a-z]+$" | head -n1)
[[ ! -f "$cover" ]] && { reset_background ; exit 1 ; }
tmp_cover="/tmp/$(basename $cover)"
if [[ -f "$cover" ]]; then
# resize the image's width to 600px
MAGICK_OCL_DEVICE=OFF magick "$cover" -resize 600x "$tmp_cover"
fi
printf "\e]20;${tmp_cover};45x45+50+95:op=keep-aspect\a"
if [[ ! -f "$cover" ]]; then
reset_background
fi
} &