Does not work with zsh
When I run the script I get a zsh: = not found error. The problem lies with the == checks in bing_wallpaper.sh#L26-L44 (see http://slopjong.de/2012/07/02/compatibility-between-zsh-and-bash/).
Dear Richard,
you propose replacement of "==" with "=" in l 26 - 44 of bing_wallpaper.sh. Am I right?
Cheers,
Daniela
From: Richard Decal [[email protected]] Sent: Tuesday, 5 September 2017 2:00 AM To: marguerite/linux-bing-wallpaper Cc: Subscribed Subject: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
When I run the script I get a zsh: = not found error. The problem lies with the == checks in bing_wallpaper.sh#L26-L44https://github.com/marguerite/linux-bing-wallpaper/blob/master/bing_wallpaper.sh#L26-L44 (see http://slopjong.de/2012/07/02/compatibility-between-zsh-and-bash/).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSMwFa-F10pOF5qKRfKRFVBhq0Ah1jks5sfB6hgaJpZM4PMFDT.
Dear Richard:
Can you test the below script and let me know the result, please? The script is available on https://github.com/dzmanto/linux-bing-wallpaper.
Cheers,
Dani
#!/bin/sh
Author: Marguerite Su [email protected], dzmanto [email protected]
License: GPL-3.0
Description: Download Bing Wallpaper of the Day and set it as your Linux Desktop.
https://github.com/marguerite/linux-bing-wallpaper
global options
$bing is needed to form the fully qualified URL for
the Bing pic of the day
bing="www.bing.com"
The idx parameter determines where to start from. 0 is the current day,
1 the previous day, etc.
idx="0"
$xmlURL is needed to get the xml data from which
the relative URL for the Bing pic of the day is extracted
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=$idx&n=1&mkt=$mkt"
Set picture options
Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned
picOpts="stretched"
The file extension for the Bing pic
picExt=".jpg"
contains() { local value=$(eval "echo $$#") count=1 for i in $* do if [ "$i" = "$value" -a $count -lt $# ]; then echo "y" return 0 fi count=$(expr $count + 1) done echo "n" return 1 }
checkdep() { tool=$(which $1) if [ ! -x "$tool" ]; then echo "Linux-bing-wallpaper depends on $1." echo "Install $1, please." echo "Exit." exit 1 fi }
ctfn () { tfnns=$(mktemp /tmp/bing_wallpaper_XXXXXX) tfn="$tfnns$picExt" mv "$tfnns" "$tfn" echo "$tfn" }
detectDE() { # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 unset GREP_OPTIONS
uname -a | grep -i darwin 2>&1 >/dev/null && DE="mac";
if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
case "${XDG_CURRENT_DESKTOP}" in
'GNOME'|'gnome')
DE="gnome"
;;
'KDE'|'kde')
DE="kde"
;;
'LXDE'|'lxde')
DE="lxde"
;;
'LXQt'|'lxqt')
DE="lxqt"
;;
'MATE'|'mate')
DE="mate"
;;
'XFCE'|'xfce')
DE="xfce"
;;
'X-Cinnamon'|'x-cinnamon')
DE="cinnamon"
;;
esac
fi
if [ -z "$DE" ]; then
# classic fallbacks
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE="kde";
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE="gnome";
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE="mate";
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE="gnome";
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE="xfce";
elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE="xfce";
fi
fi
if [ -z "$DE" ]; then
# fallback to checking $DESKTOP_SESSION
case "$DESKTOP_SESSION" in
'gnome')
DE="gnome"
;;
'LXDE'|'Lubuntu'|'lxde'|'lubuntu')
DE="lxde"
;;
'MATE'|'mate')
DE="mate"
;;
'xfce'|'xfce4'|'Xfce Session'|'xfce session')
DE="xfce"
;;
esac
fi
if [ x"$DE" = x"gnome" ]; then
# gnome-default-applications-properties is only available in GNOME 2.x
# but not in GNOME 3.x
which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3"
fi
# DE not found, maybe used WM
if [ -z "$DE" ]; then
DE="WM"
fi
echo $DE
}
helpme() { echo "Usage: bing_wallpaper.sh [market,runonce]" echo "Generic option:" echo " --help show this help" echo "Wallpaper parameters:" echo " market: de_CH, de_DE, en_AU, en_CA, en_NZ, en_UK, en-US, ja_JP, or zh_CN" echo " runonce: true or false" echo " Note that market and runonce must be specified together or not at all." }
for j do if [ "$j" = "--help" -o "$j" = "-h" ]; then helpme exit fi done
checkdep "curl" checkdep "egrep"
if [ $# -eq 0 ]; then
The mkt parameter determines which Bing market you would like to
obtain your images from.
mkt="zh-CN"
Try and guess language
ML=$(echo $LANG | cut -f 1 -d .) case $ML in 'en_US') mkt="en-US" ;; 'zh_CN') mkt="zh-CN" ;; 'ja_JP') mkt="ja-JP" ;; 'en_AU') mkt="en-AU" ;; 'en_UK') mkt="en-UK" ;; 'de_CH') mkt="de-DE" ;; 'de_DE') mkt="de-DE" ;; 'en_NZ') mkt="en-NZ" ;; 'en_CA') mkt="en-CA" ;; esac exitAfterRunning=false
elif [ $# -eq 2 ]; then list="de-DE en-AU en-CA en-NZ en-UK en-US ja-JP zh-CN"
Valid values are:
firstpar="$1" #inhibit code injection firstpar=$(echo "$firstpar" | sed s/[^a-zA-Z-]// ) if [ "$(contains $list $firstpar)" = "y" ]; then mkt=$firstpar else echo "mkt must be one of the following:" printf '%s\n' "$list" exit 1 fi
if [ "$2" = true ]; then exitAfterRunning=true else exitAfterRunning=false fi
else
echo "Usage: basename $0 mkt[en-US,zh-CN,ja-JP,en-AU,en-UK,de-DE,en-NZ,en-CA] exitAfterRunning[true,false]"
exit 1
fi
set target filename
tfn=$(ctfn)
Download the highest resolution
while true; do
picName=""
picURL=""
for picRes in _1920x1200 _1920x1080 _1366x768 _1280x720 _1024x768; do
# Extract the relative URL of the Bing pic of the day from
# the XML data retrieved from xmlURL, form the fully qualified
# URL for the pic of the day, and store it in $picURL
picURL=$bing$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$picRes$picExt
# Download the Bing pic of the day
curl -H "Content-Type: text/html; charset=UTF-8" -s -o "$tfn" -L "$picURL"
# Test if download was successful.
downloadResult=$?
if [ $downloadResult -ge 1 ]; then
rm -f "$tfn" && continue
elif [ ! -s "$tfn" ]; then
rm -f "$tfn" && continue
fi
if [ -x "/usr/bin/convert" -a -x "/usr/bin/mogrify" ]; then
title=$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<copyright>(.*)</copyright>" | cut -d ">" -f 2 | cut -d "<" -f 1 )
convert "$tfn" -resize 1920x1200 "$tfn"
convert -background "#00000080" -fill white -gravity center -size 1024 -font "Droid Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity south -composite "$tfn"
fi
# Test if it's a pic
file --mime-type -b "$tfn" | grep "^image/" > /dev/null && break
rm -f "$tfn"
done
if [ $downloadResult -ge 1 ]; then
echo "Failed to download any picture."
echo "Try again in 60 seconds."
sleep 60
continue
fi
DE=$(detectDE)
if [ "$DE" = "cinnamon" ]; then
# Set the Cinnamon wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-uri '"file://'$tfn'"'
# Set the Cinnamon wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-options $picOpts
elif [ "$DE" = "gnome" ]; then
checkdep "gconftool"
# Set the GNOME 2 wallpaper
gconftool-2 -s -t string /desktop/gnome/background/picture_filename "$tfn"
# Set the GNOME 2 wallpaper picture options
gconftool-2 -s -t string /desktop/gnome/background/picture_options "$picOpts"
elif [ "$DE" = "gnome3" ]; then
checkdep "gsettings"
# Set the GNOME3 wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$tfn'"'
# Set the GNOME 3 wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts
gsettings set org.gnome.desktop.background picture-uri '"file://'$tfn'"'
elif [ "$DE" = "kde" ]; then
checkdep "xdotool"
checkdep "gettext"
LOCALE=$(echo $LANG | sed 's/\..*$//')
EN_CONSOLE1="Desktop Shell Scripting Console"
EN_CONSOLE2="Plasma Desktop Shell"
if [ -n $LOCALE ]; then
JS_CONSOLE1=$(LANGUAGE=$LOCALE gettext -d plasma-desktop -s "$EN_CONSOLE1")
JS_CONSOLE2=$(LANGUAGE=$LOCALE gettext -d plasma-desktop -s "$EN_CONSOLE2")
JS_CONSOLE="$JS_CONSOLE1 – $JS_CONSOLE2"
else
JS_CONSOLE="$EN_CONSOLE1 – $EN_CONSOLE2"
fi
js=$(mktemp)
cat << _EOF > $js
var wallpaper = "$tfn"; var activity = activities()[0]; activity.currentConfigGroup = new Array("Wallpaper", "image"); activity.writeConfig("wallpaper", wallpaper); activity.writeConfig("userswallpaper", wallpaper); activity.reloadConfig(); _EOF qdbus org.kde.plasma-desktop /App local.PlasmaApp.loadScriptInInteractiveConsole "$js" > /dev/null xdotool search --name "$JS_CONSOLE" windowactivate key ctrl+e key ctrl+w rm -f "$js"
elif [ "$DE" = "lxde" ]; then
checkdep "pcmanfm"
pcmanfm -w "$tfn"
pcmanfm --wallpaper-mode=center
pcmanfm --wallpaper-mode=stretch
elif [ "$DE" = "lxqt" ]; then
checkdep "pcmanfm-qt"
pcmanfm-qt -w "$tfn"
elif [ "$DE" = "mac" ]; then
# set target filename 4 mac
tfnnew=$(ctfn)
mv $tfn $tfnnew
rm -f $tfnold
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'"$tfnnew"'"'
osafirstResult=$?
osascript -e 'tell application "System Events" to set picture of every desktop to "'"$tfnnew"'"'
osasecondResult=$?
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$tfnnew'" 2>&1 >/dev/null
sqliteResult=$?
tfnold=$tfnnew
elif [ "$DE" = "mate" ]; then
checkdep "dconf"
dconf write /org/mate/desktop/background/picture-filename '"'$tfn'"'
elif [ "$DE" = "xfce" ]; then
checkdep "xfconf-query"
# set to every monitor that contains image-path/last-image
properties=$(xfconf-query -c xfce4-desktop -p /backdrop -l | grep -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$")
for property in $properties; do
xfconf-query -c xfce4-desktop -p $property -s "$tfn"
done
elif [ $DE = "WM" ]; then
checkdep "feh"
feh --bg-tile "$tfn"
fi
if [ "$exitAfterRunning" = true ] ; then
# Exit the script
exit 0
fi
# sleep for half a day
DIFF_TIME=0
LAST_RUN=$(date +%s)
LAST_DAY=$(date +%A)
LAST_HOUR=$(date +%I)
while [ $DIFF_TIME -lt 43199 ]; do
NOW=$(date +%s)
DIFF_TIME=$(expr $NOW - $LAST_RUN)
sleep 60
done
done
From: Richard Decal [[email protected]] Sent: Tuesday, 5 September 2017 2:00 AM To: marguerite/linux-bing-wallpaper Cc: Subscribed Subject: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
When I run the script I get a zsh: = not found error. The problem lies with the == checks in bing_wallpaper.sh#L26-L44https://github.com/marguerite/linux-bing-wallpaper/blob/master/bing_wallpaper.sh#L26-L44 (see http://slopjong.de/2012/07/02/compatibility-between-zsh-and-bash/).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSMwFa-F10pOF5qKRfKRFVBhq0Ah1jks5sfB6hgaJpZM4PMFDT.
Thanks for your quick response! Here's the output:
✘ crypdick@laptop ~ bash bing_wallpaper.sh en-US true
convert: unable to read font `Droid Sans' @ warning/annotate.c/RenderType/964.
convert: unable to read font `Droid Sans' @ error/annotate.c/RenderFreetype/1362.
convert: unable to read font `Droid Sans' @ warning/annotate.c/RenderType/964.
convert: unable to read font `Droid Sans' @ error/annotate.c/RenderFreetype/1362.
convert: no such image `/tmp/bing_wallpaper_rxhBgS.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined `/tmp/bing_wallpaper_rxhBgS.jpg' @ error/convert.c/ConvertImageCommand/3258.
Dear Richard:
Can you let me know the output of ls -l /tmp/bing_wallpaper_rxhBgS.jpg on your machine, please?
Cheers,
Daniela
From: Richard Decal [[email protected]] Sent: Wednesday, 6 September 2017 9:10 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Comment Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Thanks for your quick response! Here's the output:
✘ crypdick@laptop ~ bash bing_wallpaper.sh en-US true
convert: unable to read font Droid Sans' @ warning/annotate.c/RenderType/964. convert: unable to read font Droid Sans' @ error/annotate.c/RenderFreetype/1362.
convert: unable to read font Droid Sans' @ warning/annotate.c/RenderType/964. convert: unable to read font Droid Sans' @ error/annotate.c/RenderFreetype/1362.
convert: no such image /tmp/bing_wallpaper_rxhBgS.jpg' @ error/mogrify.c/MogrifyImageList/8775. convert: no images defined /tmp/bing_wallpaper_rxhBgS.jpg' @ error/convert.c/ConvertImageCommand/3258.
— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-327328663, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM8Ucp1NQWNPn5hoHGfZIoRgWy0ggks5sfdTxgaJpZM4PMFDT.
@dzmanto:
-rw------- 1 crypdick crypdick 517457 Sep 5 19:09 /tmp/bing_wallpaper_rxhBgS.jpg
crypdick@laptop ~ which mogrify
/usr/bin/mogrify
crypdick@laptop ~ mogrify /tmp/bing_wallpaper_rxhBgS.jpg
crypdick@laptop ~
Dear Richard:
Thank you for your quick reply.
The image file /tmp/bing_wallpaper_rxhBgS.jpg appears to be of non-zero size. Can you please open /tmp/bing_wallpaper_rxhBgS.jpg with your preferred image viewer and verify that /tmp/bing_wallpaper_rxhBgS.jpg contains an image?
Cheers,
Daniela
From: Richard Decal [[email protected]] Sent: Wednesday, 6 September 2017 10:15 PM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
@dzmantohttps://github.com/dzmanto:
crypdick@laptop ~ ls -l /tmp/bing_wallpaper_rxhBgS.jpg -rw------- 1 crypdick crypdick 517457 Sep 5 19:09 /tmp/bing_wallpaper_rxhBgS.jpg
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-327464865, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM51CfkfB2I-tL2WnnNc67Fe7PrASks5sfozrgaJpZM4PMFDT.
Yep.

Dear Richard:
Does the script change your desktop wallpaper? What desktop environment are you using?
Cheers,
Daniela
From: Richard Decal [[email protected]] Sent: Thursday, 7 September 2017 1:02 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Yep. [bing_wallpaper_rxhbgs]https://user-images.githubusercontent.com/5415776/30119123-c19c5286-92f2-11e7-952d-a22d32fd4823.jpg
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-327512181, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM_8UR2PNI7SxWPqeD96Z0HW2JuQlks5sfrPqgaJpZM4PMFDT.
I'm using i3. I just tried disabling nitrogen and enabling compton and it looks like it's working now! Thanks for the help Daniela :1st_place_medal:
Hi Richard,
would you mind checking if the below script avoids the missing font issue?
Cheers,
Daniela
#!/bin/sh
Author: Marguerite Su [email protected], dzmanto [email protected]
License: GPL-3.0
Description: Download Bing Wallpaper of the Day and set it as your Linux Desktop.
https://github.com/marguerite/linux-bing-wallpaper
global options
$bing is needed to form the fully qualified URL for
the Bing pic of the day
bing="www.bing.com"
The idx parameter determines where to start from. 0 is the current day,
1 the previous day, etc.
idx="0"
$xmlURL is needed to get the xml data from which
the relative URL for the Bing pic of the day is extracted
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=$idx&n=1&mkt=$mkt"
Set picture options
Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned
picOpts="stretched"
The file extension for the Bing pic
picExt=".jpg"
contains() { local value=$(eval "echo $$#") count=1 for i in $* do if [ "$i" = "$value" -a $count -lt $# ]; then echo "y" return 0 fi count=$(expr $count + 1) done echo "n" return 1 }
checkdep() { tool=$(which $1) if [ ! -x "$tool" ]; then echo "Linux-bing-wallpaper depends on $1." echo "Install $1, please." echo "Exit." exit 1 fi }
ctfn () { tfnns=$(mktemp /tmp/bing_wallpaper_XXXXXX) tfn="$tfnns$picExt" mv "$tfnns" "$tfn" echo "$tfn" }
detectDE() { # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 unset GREP_OPTIONS
uname -a | grep -i darwin 2>&1 >/dev/null && DE="mac";
if [ -n "${XDG_CURRENT_DESKTOP}" ]; then case "${XDG_CURRENT_DESKTOP}" in 'GNOME'|'gnome') DE="gnome" ;; 'KDE'|'kde') DE="kde" ;; 'LXDE'|'lxde') DE="lxde" ;; 'LXQt'|'lxqt') DE="lxqt" ;; 'MATE'|'mate') DE="mate" ;; 'XFCE'|'xfce') DE="xfce" ;; 'X-Cinnamon'|'x-cinnamon') DE="cinnamon" ;; esac fi
if [ -z "$DE" ]; then
# classic fallbacks
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE="kde";
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE="gnome";
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE="mate";
elif dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1 ; then DE="gnome";
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = "xfce4"$' >/dev/null 2>&1; then DE="xfce";
elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE="xfce";
fi
fi
if [ -z "$DE" ]; then # fallback to checking $DESKTOP_SESSION case "$DESKTOP_SESSION" in 'gnome') DE="gnome" ;; 'LXDE'|'Lubuntu'|'lxde'|'lubuntu') DE="lxde" ;; 'MATE'|'mate') DE="mate" ;; 'xfce'|'xfce4'|'Xfce Session'|'xfce session') DE="xfce" ;; esac fi
if [ x"$DE" = x"gnome" ]; then # gnome-default-applications-properties is only available in GNOME 2.x # but not in GNOME 3.x which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3" fi # DE not found, maybe used WM if [ -z "$DE" ]; then DE="WM" fi echo $DE }
helpme() { echo "Usage: bing_wallpaper.sh [market,runonce]" echo "Generic option:" echo " --help show this help" echo "Wallpaper parameters:" echo " market: de_CH, de_DE, en_AU, en_CA, en_NZ, en_UK, en-US, ja_JP, or zh_CN" echo " runonce: true or false" echo " Note that market and runonce must be specified together or not at all." }
for j do if [ "$j" = "--help" -o "$j" = "-h" ]; then helpme exit fi done
checkdep "curl" checkdep "egrep"
if [ $# -eq 0 ]; then # The mkt parameter determines which Bing market you would like to # obtain your images from.
mkt="zh-CN" # Try and guess language ML=$(echo $LANG | cut -f 1 -d .) case $ML in 'en_US') mkt="en-US" ;; 'zh_CN') mkt="zh-CN" ;; 'ja_JP') mkt="ja-JP" ;; 'en_AU') mkt="en-AU" ;; 'en_UK') mkt="en-UK" ;; 'de_CH') mkt="de-DE" ;; 'de_DE') mkt="de-DE" ;; 'en_NZ') mkt="en-NZ" ;; 'en_CA') mkt="en-CA" ;; esac exitAfterRunning=false
elif [ $# -eq 2 ]; then list="de-DE en-AU en-CA en-NZ en-UK en-US ja-JP zh-CN" # Valid values are: firstpar="$1" #inhibit code injection firstpar=$(echo "$firstpar" | sed s/[^a-zA-Z-]// ) if [ "$(contains $list $firstpar)" = "y" ]; then mkt=$firstpar else echo "mkt must be one of the following:" printf '%s\n' "$list" exit 1 fi
if [ "$2" = true ]; then exitAfterRunning=true else exitAfterRunning=false fi
else
echo "Usage: basename $0 mkt[en-US,zh-CN,ja-JP,en-AU,en-UK,de-DE,en-NZ,en-CA] exitAfterRunning[true,false]"
exit 1
fi
set target filename
tfn=$(ctfn)
Download the highest resolution
while true; do
picName="" picURL="" for picRes in _1920x1200 _1920x1080 _1366x768 _1280x720 _1024x768; do
# Extract the relative URL of the Bing pic of the day from # the XML data retrieved from xmlURL, form the fully qualified # URL for the pic of the day, and store it in $picURL picURL=$bing$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$picRes$picExt
# Download the Bing pic of the day curl -H "Content-Type: text/html; charset=UTF-8" -s -o "$tfn" -L "$picURL"
# Test if download was successful. downloadResult=$? if [ $downloadResult -ge 1 ]; then rm -f "$tfn" && continue elif [ ! -s "$tfn" ]; then rm -f "$tfn" && continue fi
if [ -x "/usr/bin/convert" -a -x "/usr/bin/mogrify" ]; then
title=$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "
rm -f "$tfn" done
if [ $downloadResult -ge 1 ]; then echo "Failed to download any picture." echo "Try again in 60 seconds." sleep 60 continue fi
DE=$(detectDE)
if [ "$DE" = "cinnamon" ]; then # Set the Cinnamon wallpaper DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-uri '"file://'$tfn'"'
# Set the Cinnamon wallpaper picture options DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-options $picOpts elif [ "$DE" = "gnome" ]; then checkdep "gconftool" # Set the GNOME 2 wallpaper gconftool-2 -s -t string /desktop/gnome/background/picture_filename "$tfn" # Set the GNOME 2 wallpaper picture options gconftool-2 -s -t string /desktop/gnome/background/picture_options "$picOpts" elif [ "$DE" = "gnome3" ]; then checkdep "gsettings" # Set the GNOME3 wallpaper DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$tfn'"'
# Set the GNOME 3 wallpaper picture options DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts gsettings set org.gnome.desktop.background picture-uri '"file://'$tfn'"' elif [ "$DE" = "kde" ]; then checkdep "xdotool" checkdep "gettext" LOCALE=$(echo $LANG | sed 's/..*$//')
EN_CONSOLE1="Desktop Shell Scripting Console" EN_CONSOLE2="Plasma Desktop Shell"
if [ -n $LOCALE ]; then JS_CONSOLE1=$(LANGUAGE=$LOCALE gettext -d plasma-desktop -s "$EN_CONSOLE1") JS_CONSOLE2=$(LANGUAGE=$LOCALE gettext -d plasma-desktop -s "$EN_CONSOLE2") JS_CONSOLE="$JS_CONSOLE1 $JS_CONSOLE2" else JS_CONSOLE="$EN_CONSOLE1 $EN_CONSOLE2" fi
js=$(mktemp) cat << _EOF > $js var wallpaper = "$tfn"; var activity = activities()[0]; activity.currentConfigGroup = new Array("Wallpaper", "image"); activity.writeConfig("wallpaper", wallpaper); activity.writeConfig("userswallpaper", wallpaper); activity.reloadConfig(); _EOF qdbus org.kde.plasma-desktop /App local.PlasmaApp.loadScriptInInteractiveConsole "$js" > /dev/null xdotool search --name "$JS_CONSOLE" windowactivate key ctrl+e key ctrl+w rm -f "$js"
elif [ "$DE" = "lxde" ]; then checkdep "pcmanfm" pcmanfm -w "$tfn" pcmanfm --wallpaper-mode=center pcmanfm --wallpaper-mode=stretch elif [ "$DE" = "lxqt" ]; then checkdep "pcmanfm-qt" pcmanfm-qt -w "$tfn" elif [ "$DE" = "mac" ]; then # set target filename 4 mac tfnnew=$(ctfn) mv $tfn $tfnnew rm -f $tfnold
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'"$tfnnew"'"' osafirstResult=$? osascript -e 'tell application "System Events" to set picture of every desktop to "'"$tfnnew"'"' osasecondResult=$? sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$tfnnew'" 2>&1 >/dev/null sqliteResult=$?
tfnold=$tfnnew elif [ "$DE" = "mate" ]; then checkdep "dconf" dconf write /org/mate/desktop/background/picture-filename '"'$tfn'"' elif [ "$DE" = "xfce" ]; then checkdep "xfconf-query" # set to every monitor that contains image-path/last-image properties=$(xfconf-query -c xfce4-desktop -p /backdrop -l | grep -e "screen./monitor.image-path$" -e "screen./monitor./last-image$")
for property in $properties; do xfconf-query -c xfce4-desktop -p $property -s "$tfn" done elif [ $DE = "WM" ]; then checkdep "feh" feh --bg-tile "$tfn" fi
if [ "$exitAfterRunning" = true ] ; then # Exit the script exit 0 fi
# sleep for half a day DIFF_TIME=0 LAST_RUN=$(date +%s) LAST_DAY=$(date +%A) LAST_HOUR=$(date +%I) while [ $DIFF_TIME -lt 43199 ]; do NOW=$(date +%s) DIFF_TIME=$(expr $NOW - $LAST_RUN) sleep 60 done done
From: Richard Decal [email protected] Sent: Thursday, 7 September 2017 1:47 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19) I'm using i3. I just tried disabling nitrogen and enabling compton and it looks like it's working now! Thanks for the help Daniela 🥇 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread. https://github.com/notifications/beacon/ALJSMx78_s_VJG4p1ysK5pRpLgrdHNjMks5sfr6AgaJpZM4PMFDT.gif
It works, but I still get font warnings.
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
convert: unable to read font `Nimbus Sans' @ warning/annotate.c/RenderType/964.
convert: unable to read font `Nimbus Sans' @ error/annotate.c/RenderFreetype/1362.
convert: unable to read font `Nimbus Sans' @ warning/annotate.c/RenderType/964.
convert: unable to read font `Nimbus Sans' @ error/annotate.c/RenderFreetype/1362.
convert: no such image `/tmp/bing_wallpaper_swfREe.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined `/tmp/bing_wallpaper_swfREe.jpg' @ error/convert.c/ConvertImageCommand/3258.
Dear Richard:
Is the image annotated at all? Is there a line of text at the bottom of the image?
Cheers,
Daniela
From: Richard Decal [email protected] Sent: Saturday, 9 September 2017 4:20 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
It works, but I still get font warnings.
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
convert: unable to read font Nimbus Sans' @ warning/annotate.c/RenderType/964. convert: unable to read font Nimbus Sans' @ error/annotate.c/RenderFreetype/1362.
convert: unable to read font Nimbus Sans' @ warning/annotate.c/RenderType/964. convert: unable to read font Nimbus Sans' @ error/annotate.c/RenderFreetype/1362.
convert: no such image /tmp/bing_wallpaper_swfREe.jpg' @ error/mogrify.c/MogrifyImageList/8775. convert: no images defined /tmp/bing_wallpaper_swfREe.jpg' @ error/convert.c/ConvertImageCommand/3258.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-328178033, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSMyUDgVFHmpPWVGa_J_GgQGDbQ6hHks5sgYVdgaJpZM4PMFDT.
Sorry for the late response, was getting hit by a hurricane. I do not see anything like that (other than the Bing logo).
Dear Richard:
Good on you for surviving Irma. I hope you and yours are alrite.
I eliminated all fonts specifications from the convert command. Does the below script still produce font errors?
Cheers,
Dani
#!/bin/sh
Author: Marguerite Su [email protected], dzmanto [email protected]
License: GPL-3.0
Description: Download Bing Wallpaper of the Day and set it as your Linux Desktop.
https://github.com/marguerite/linux-bing-wallpaper
contains() { local value=$(eval "echo $$#") count=1 for i in $* do if [ "$i" = "$value" -a $count -lt $# ]; then echo "y" return 0 fi count=$(expr $count + 1) done echo "n" return 1 }
detectDE() { # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 unset GREP_OPTIONS
uname -a | grep -i darwin 2>&1 >/dev/null && DE="mac";
if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
case "${XDG_CURRENT_DESKTOP}" in
'GNOME')
DE="gnome"
;;
'KDE')
DE="kde"
;;
'LXDE')
DE="lxde"
;;
'LXQt')
DE="lxqt"
;;
'MATE')
DE="mate"
;;
'XFCE')
DE="xfce"
;;
'X-Cinnamon')
DE="cinnamon"
;;
esac
fi
if [ x"$DE" = x"" ]; then
# classic fallbacks
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE="kde";
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE="gnome";
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE="mate";
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE="gnome";
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE="xfce";
elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE="xfce";
fi
fi
if [ x"$DE" = x"" ]; then
# fallback to checking $DESKTOP_SESSION
case "$DESKTOP_SESSION" in
'gnome')
DE="gnome"
;;
'LXDE'|'Lubuntu')
DE="lxde"
;;
'MATE')
DE="mate"
;;
'xfce'|'xfce4'|'Xfce Session')
DE="xfce"
;;
esac
fi
if [ x"$DE" = x"gnome" ]; then
# gnome-default-applications-properties is only available in GNOME 2.x
# but not in GNOME 3.x
which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3"
fi
echo $DE
}
if [ $# -eq 0 ]; then
The mkt parameter determines which Bing market you would like to
obtain your images from.
mkt="zh-CN"
Try and guess language
ML=$(echo $LANG | cut -f 1 -d .) case $ML in 'en_US') mkt="en-US" ;; 'zh_CN') mkt="zh-CN" ;; 'ja_JP') mkt="ja-JP" ;; 'en_AU') mkt="en-AU" ;; 'en_UK') mkt="en-UK" ;; 'de_CH') mkt="de-DE" ;; 'de_DE') mkt="de-DE" ;; 'en_NZ') mkt="en-NZ" ;; 'en_CA') mkt="en-CA" ;; esac exitAfterRunning=false
elif [ $# -eq 2 ]; then list="de-DE en-AU en-CA en-NZ en-UK en-US ja-JP zh-CN"
Valid values are:
firstpar="$1" #inhibit code injection firstpar=$(echo "$firstpar" | sed s/[^a-zA-Z-]// ) if [ "$(contains $list $firstpar)" = "y" ]; then mkt=$firstpar else echo "mkt must be one of the following:" printf '%s\n' "$list" exit 1 fi
if [ "$2" = true ]; then exitAfterRunning=true else exitAfterRunning=false fi
else
echo "Usage: basename $0 mkt[en-US,zh-CN,ja-JP,en-AU,en-UK,de-DE,en-NZ,en-CA] exitAfterRunning[true,false]"
exit 1
fi
$bing is needed to form the fully qualified URL for
the Bing pic of the day
bing="www.bing.com"
The idx parameter determines where to start from. 0 is the current day,
1 the previous day, etc.
idx="0"
$xmlURL is needed to get the xml data from which
the relative URL for the Bing pic of the day is extracted
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=$idx&n=1&mkt=$mkt"
$saveDir is used to set the location where Bing pics of the day
are stored. $HOME holds the path of the current user's home directory
saveDir=$HOME'/Pictures/Bing/'
Create saveDir if it does not already exist
mkdir -p $saveDir
Set picture options
Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned
picOpts="stretched"
The file extension for the Bing pic
picExt=".jpg"
Initialize counter for mac pictures
maccount=1
Download the highest resolution
while true; do
picName=""
picURL=""
for picRes in _1920x1200 _1366x768 _1280x720 _1024x768; do
# Extract the relative URL of the Bing pic of the day from
# the XML data retrieved from xmlURL, form the fully qualified
# URL for the pic of the day, and store it in $picURL
picURL=$bing$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$picRes$picExt
# $picName contains the filename of the Bing pic of the day
# picName=${picURL##*/}
picName="bing_wallpaper_$$$picExt"
# Download the Bing pic of the day
curl -H "Content-Type: text/html; charset=UTF-8" -s -o $saveDir$picName -L "$picURL"
# Test if download was successful.
downloadResult=$?
if [ $downloadResult -ge 1 ]; then
rm -f $saveDir$picName && continue
elif [ ! -s $saveDir$picName ]; then
rm -f $saveDir$picName && continue
fi
if [ -x "/usr/bin/convert" ]; then
title=$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<copyright>(.*)</copyright>" | cut -d ">" -f 2 | cut -d "<" -f 1 )
convert $saveDir$picName -resize 1920x1200 $saveDir$picName
convert -background "#00000080" -fill white -gravity center -size 1024 -pointsize 22 caption:"${title}" $saveDir$picName +swap -gravity south -composite $saveDir$picName
fi
# Test if it's a pic
file --mime-type -b $saveDir$picName | grep "^image/" > /dev/null && break
rm -f $saveDir$picName
done
if [ $downloadResult -ge 1 ]; then
echo "Failed to download any picture."
echo "Try again in 60 seconds."
sleep 60
continue
fi
DE=$(detectDE)
if [ "$DE" = "cinnamon" ]; then
# Set the Cinnamon wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-uri '"file://'$saveDir$picName'"'
# Set the Cinnamon wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-options $picOpts
elif [ "$DE" = "gnome" ]; then
# Set the GNOME 2 wallpaper
gconftool-2 -s -t string /desktop/gnome/background/picture_filename "$saveDir$picName"
# Set the GNOME 2 wallpaper picture options
gconftool-2 -s -t string /desktop/gnome/background/picture_options "$picOpts"
elif [ "$DE" = "gnome3" ]; then
# Set the GNOME3 wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$saveDir$picName'"'
# Set the GNOME 3 wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts
gsettings set org.gnome.desktop.background picture-uri '"file://'$saveDir$picName'"'
elif [ "$DE" = "kde" ]; then
test -e /usr/bin/xdotool || sudo zypper --no-refresh install xdotool
test -e /usr/bin/gettext || sudo zypper --no-refresh install gettext-runtime
./kde4_set_wallpaper.sh $saveDir$picName
elif [ "$DE" = "lxqt" ] ; then
pcmanfm-qt -w $saveDir$picName
elif [ "$DE" = "mac" ]; then
fn=$saveDir$picName
# python - $fn << EOF
from appscript import app, mactypes
import argparse
def main():
parser = argparse.ArgumentParser(description='Set desktop wallpaper.')
parser.add_argument('file', type=file, help='File to use as wallpaper.')
args = parser.parse_args()
f = args.file
app('finder').desktop_picture.set(mactypes.File(f.name))
se = app('System Events')
desktops = se.desktops.display_name.get()
for d in desktops:
desk = se.desktops[its.display_name == d]
desk.picture.set(mactypes.File(f.name))
main()
EOF
maccount=$(expr $maccount + 1)
fnnew="$fn$maccount"
mv $fn $fnnew
rm -f $fnold
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'"$fnnew"'"'
osafirstResult=$?
osascript -e 'tell application "System Events" to set picture of every desktop to "'"$fnnew"'"'
osasecondResult=$?
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$fnnew'" 2>&1 >/dev/null
sqliteResult=$?
fnold=$fnnew
# if [ $osafirstResult -ge 1 -a $osasecondResult -ge 1 -a $sqliteResult -ge 1 ]; then
# echo "Failed to refresh desktop image."
# echo "Try again in 60 seconds."
# sleep 60
# continue
# fi
elif [ "$DE" = "mate" ]; then
dconf write /org/mate/desktop/background/picture-filename '"'$saveDir$picName'"'
elif [ "$DE" = "xfce" ]; then
./xfce4_set_wallpaper.sh $saveDir$picName
fi
if [ "$exitAfterRunning" = true ] ; then
# Exit the script
exit 0
fi
# sleep for half a day
DIFF_TIME=0
LAST_RUN=$(date +%s)
while [ $DIFF_TIME -lt 43199 ]; do
NOW=$(date +%s)
DIFF_TIME=$(expr $NOW - $LAST_RUN)
sleep 60
done
done
From: Richard Decal [email protected] Sent: Wednesday, 13 September 2017 4:29 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Sorry for the late response, was getting hit by a hurricane. I do not see anything like that (other than the Bing logo).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-328941427, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM3g7fGcXpXYiowyP5Oafr8N92NRtks5shs1tgaJpZM4PMFDT.
Thanks! I made it through fine ^_^ I ran this script twice. Both times, it downloaded the photo of the day and saved it using a different filename (don't know if that's intended behavior) but this time my wallpaper did not get replaced.
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
convert: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362.
convert: no such image `/home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined `/home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/convert.c/ConvertImageCommand/3258.
✘ crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
convert: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362.
convert: no such image `/home/crypdick/Pictures/Bing/bing_wallpaper_21110.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined `/home/crypdick/Pictures/Bing/bing_wallpaper_21110.jpg' @ error/convert.c/ConvertImageCommand/3258.
Dear Richard:
I would like to confirm that the font command is the culprit, so I now removed the annotation command and kept only the convert resize command.
Can you run the below code and report back, please?
BTW, are you on MAC OS?
Cheers,
Dani
#!/bin/sh
Author: Marguerite Su [email protected], dzmanto [email protected]
License: GPL-3.0
Description: Download Bing Wallpaper of the Day and set it as your Linux Desktop.
https://github.com/marguerite/linux-bing-wallpaper
global options
$bing is needed to form the fully qualified URL for
the Bing pic of the day
bing="www.bing.com"
The idx parameter determines where to start from. 0 is the current day,
1 the previous day, etc.
idx="0"
$xmlURL is needed to get the xml data from which
the relative URL for the Bing pic of the day is extracted
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=$idx&n=1&mkt=$mkt"
Set picture options
Valid options are: none,wallpaper,centered,scaled,stretched,zoom,spanned
picOpts="stretched"
The file extension for the Bing pic
picExt=".jpg"
contains() { local value=$(eval "echo $$#") count=1 for i in $* do if [ "$i" = "$value" -a $count -lt $# ]; then echo "y" return 0 fi count=$(expr $count + 1) done echo "n" return 1 }
checkdep() { tool=$(which $1) if [ ! -x "$tool" ]; then echo "Linux-bing-wallpaper depends on $1." echo "Install $1, please." echo "Exit." exit 1 fi }
ctfn () { tfnns=$(mktemp /tmp/bing_wallpaper_XXXXXX) tfn="$tfnns$picExt" mv "$tfnns" "$tfn" echo "$tfn" }
detectDE() { # see https://bugs.freedesktop.org/show_bug.cgi?id=34164 unset GREP_OPTIONS
uname -a | grep -i darwin 2>&1 >/dev/null && DE="mac";
if [ -n "${XDG_CURRENT_DESKTOP}" ]; then
case "${XDG_CURRENT_DESKTOP}" in
'GNOME'|'gnome')
DE="gnome"
;;
'KDE'|'kde')
DE="kde"
;;
'LXDE'|'lxde')
DE="lxde"
;;
'LXQt'|'lxqt')
DE="lxqt"
;;
'MATE'|'mate')
DE="mate"
;;
'XFCE'|'xfce')
DE="xfce"
;;
'X-Cinnamon'|'x-cinnamon')
DE="cinnamon"
;;
esac
fi
if [ -z "$DE" ]; then
# classic fallbacks
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE="kde";
elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE="gnome";
elif [ x"$MATE_DESKTOP_SESSION_ID" != x"" ]; then DE="mate";
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE="gnome";
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE="xfce";
elif xprop -root 2> /dev/null | grep -i '^xfce_desktop_window' >/dev/null 2>&1; then DE="xfce";
fi
fi
if [ -z "$DE" ]; then
# fallback to checking $DESKTOP_SESSION
case "$DESKTOP_SESSION" in
'gnome')
DE="gnome"
;;
'LXDE'|'Lubuntu'|'lxde'|'lubuntu')
DE="lxde"
;;
'MATE'|'mate')
DE="mate"
;;
'xfce'|'xfce4'|'Xfce Session'|'xfce session')
DE="xfce"
;;
esac
fi
if [ x"$DE" = x"gnome" ]; then
# gnome-default-applications-properties is only available in GNOME 2.x
# but not in GNOME 3.x
which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3"
fi
# DE not found, maybe used WM
if [ -z "$DE" ]; then
DE="WM"
fi
echo $DE
}
helpme() { echo "Usage: bing_wallpaper.sh [market,runonce]" echo "Generic option:" echo " --help show this help" echo "Wallpaper parameters:" echo " market: de_CH, de_DE, en_AU, en_CA, en_NZ, en_UK, en-US, ja_JP, or zh_CN" echo " runonce: true or false" echo " Note that market and runonce must be specified together or not at all." }
for j do if [ "$j" = "--help" -o "$j" = "-h" ]; then helpme exit fi done
checkdep "curl" checkdep "egrep"
if [ $# -eq 0 ]; then
The mkt parameter determines which Bing market you would like to
obtain your images from.
mkt="zh-CN"
Try and guess language
ML=$(echo $LANG | cut -f 1 -d .) case $ML in 'en_US') mkt="en-US" ;; 'zh_CN') mkt="zh-CN" ;; 'ja_JP') mkt="ja-JP" ;; 'en_AU') mkt="en-AU" ;; 'en_UK') mkt="en-UK" ;; 'de_CH') mkt="de-DE" ;; 'de_DE') mkt="de-DE" ;; 'en_NZ') mkt="en-NZ" ;; 'en_CA') mkt="en-CA" ;; esac exitAfterRunning=false
elif [ $# -eq 2 ]; then list="de-DE en-AU en-CA en-NZ en-UK en-US ja-JP zh-CN"
Valid values are:
firstpar="$1" #inhibit code injection firstpar=$(echo "$firstpar" | sed s/[^a-zA-Z-]// ) if [ "$(contains $list $firstpar)" = "y" ]; then mkt=$firstpar else echo "mkt must be one of the following:" printf '%s\n' "$list" exit 1 fi
if [ "$2" = true ]; then exitAfterRunning=true else exitAfterRunning=false fi
else
echo "Usage: basename $0 mkt[en-US,zh-CN,ja-JP,en-AU,en-UK,de-DE,en-NZ,en-CA] exitAfterRunning[true,false]"
exit 1
fi
set target filename
tfn=$(ctfn)
Download the highest resolution
while true; do
picName=""
picURL=""
for picRes in _1920x1200 _1920x1080 _1366x768 _1280x720 _1024x768; do
# Extract the relative URL of the Bing pic of the day from
# the XML data retrieved from xmlURL, form the fully qualified
# URL for the pic of the day, and store it in $picURL
picURL=$bing$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$picRes$picExt
# Download the Bing pic of the day
curl -H "Content-Type: text/html; charset=UTF-8" -s -o "$tfn" -L "$picURL"
# Test if download was successful.
downloadResult=$?
if [ $downloadResult -ge 1 ]; then
rm -f "$tfn" && continue
elif [ ! -s "$tfn" ]; then
rm -f "$tfn" && continue
fi
if [ -x "/usr/bin/convert" -a -x "/usr/bin/mogrify" ]; then
title=$(echo $(curl -H "Content-Type: text/html; charset=UTF-8" -L -s $xmlURL) | egrep -o "<copyright>(.*)</copyright>" | cut -d ">" -f 2 | cut -d "<" -f 1 )
convert "$tfn" -resize 1920x1200 "$tfn"
fi
# Test if it's a pic
file --mime-type -b "$tfn" | grep "^image/" > /dev/null && break
rm -f "$tfn"
done
if [ $downloadResult -ge 1 ]; then
echo "Failed to download any picture."
echo "Try again in 60 seconds."
sleep 60
continue
fi
DE=$(detectDE)
if [ "$DE" = "cinnamon" ]; then
# Set the Cinnamon wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-uri '"file://'$tfn'"'
# Set the Cinnamon wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.cinnamon.desktop.background picture-options $picOpts
elif [ "$DE" = "gnome" ]; then
checkdep "gconftool"
# Set the GNOME 2 wallpaper
gconftool-2 -s -t string /desktop/gnome/background/picture_filename "$tfn"
# Set the GNOME 2 wallpaper picture options
gconftool-2 -s -t string /desktop/gnome/background/picture_options "$picOpts"
elif [ "$DE" = "gnome3" ]; then
checkdep "gsettings"
# Set the GNOME3 wallpaper
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$tfn'"'
# Set the GNOME 3 wallpaper picture options
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-options $picOpts
gsettings set org.gnome.desktop.background picture-uri '"file://'$tfn'"'
elif [ "$DE" = "kde" ]; then
checkdep "xdotool"
checkdep "gettext"
LOCALE=$(echo $LANG | sed 's/\..*$//')
EN_CONSOLE1="Desktop Shell Scripting Console"
EN_CONSOLE2="Plasma Desktop Shell"
if [ -n $LOCALE ]; then
JS_CONSOLE1=$(LANGUAGE=$LOCALE gettext -d plasma-desktop -s "$EN_CONSOLE1")
JS_CONSOLE2=$(LANGUAGE=$LOCALE gettext -d plasma-desktop -s "$EN_CONSOLE2")
JS_CONSOLE="$JS_CONSOLE1 – $JS_CONSOLE2"
else
JS_CONSOLE="$EN_CONSOLE1 – $EN_CONSOLE2"
fi
js=$(mktemp)
cat << _EOF > $js
var wallpaper = "$tfn"; var activity = activities()[0]; activity.currentConfigGroup = new Array("Wallpaper", "image"); activity.writeConfig("wallpaper", wallpaper); activity.writeConfig("userswallpaper", wallpaper); activity.reloadConfig(); _EOF qdbus org.kde.plasma-desktop /App local.PlasmaApp.loadScriptInInteractiveConsole "$js" > /dev/null xdotool search --name "$JS_CONSOLE" windowactivate key ctrl+e key ctrl+w rm -f "$js"
elif [ "$DE" = "lxde" ]; then
checkdep "pcmanfm"
pcmanfm -w "$tfn"
pcmanfm --wallpaper-mode=center
pcmanfm --wallpaper-mode=stretch
elif [ "$DE" = "lxqt" ]; then
checkdep "pcmanfm-qt"
pcmanfm-qt -w "$tfn"
elif [ "$DE" = "mac" ]; then
# set target filename 4 mac
tfnnew=$(ctfn)
mv $tfn $tfnnew
rm -f $tfnold
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'"$tfnnew"'"'
osafirstResult=$?
osascript -e 'tell application "System Events" to set picture of every desktop to "'"$tfnnew"'"'
osasecondResult=$?
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '$tfnnew'" 2>&1 >/dev/null
sqliteResult=$?
tfnold=$tfnnew
elif [ "$DE" = "mate" ]; then
checkdep "dconf"
dconf write /org/mate/desktop/background/picture-filename '"'$tfn'"'
elif [ "$DE" = "xfce" ]; then
checkdep "xfconf-query"
# set to every monitor that contains image-path/last-image
properties=$(xfconf-query -c xfce4-desktop -p /backdrop -l | grep -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$")
for property in $properties; do
xfconf-query -c xfce4-desktop -p $property -s "$tfn"
done
elif [ $DE = "WM" ]; then
checkdep "feh"
feh --bg-tile "$tfn"
fi
if [ "$exitAfterRunning" = true ] ; then
# Exit the script
exit 0
fi
# sleep for half a day
DIFF_TIME=0
LAST_RUN=$(date +%s)
LAST_DAY=$(date +%A)
LAST_HOUR=$(date +%I)
while [ $DIFF_TIME -lt 43199 ]; do
NOW=$(date +%s)
DIFF_TIME=$(expr $NOW - $LAST_RUN)
sleep 60
done
done
From: Richard Decal [email protected] Sent: Thursday, 14 September 2017 12:10 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
I made it through fine ^_^ I ran this script twice. Both times, it downloaded the photo of the day and saved it using a different filename (don't know if that's intended behavior) but this time my wallpaper did not get replaced.
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
convert: unable to read font (null)' @ error/annotate.c/RenderFreetype/1362. convert: no such image /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/convert.c/ConvertImageCommand/3258. ✘ crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh convert: unable to read font (null)' @ error/annotate.c/RenderFreetype/1362.
convert: no such image /home/crypdick/Pictures/Bing/bing_wallpaper_21110.jpg' @ error/mogrify.c/MogrifyImageList/8775. convert: no images defined /home/crypdick/Pictures/Bing/bing_wallpaper_21110.jpg' @ error/convert.c/ConvertImageCommand/3258.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-329179382, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM0psbumrQK_X0-7hMcSFVqty9J9Oks5sh-HigaJpZM4PMFDT.
^ this worked flawlessly :) I'm on Manjaro Linux.
Hi Richard:
This should indeed narrow down the list of root causes. Can you send me the output of the following command, please?
convert -background "#00000080" -fill white -gravity center -size 1024 -font "Arial" -pointsize 22 caption:"test title" /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg +swap -gravity south -composite /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg
Cheers,
Daniela
From: Richard Decal [email protected] Sent: Thursday, 14 September 2017 5:50 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
^ this worked flawlessly :) I'm on Manjaro Linux.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-329277660, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM_TCoE-W-BUPe3sSV4SaGOhdV2geks5siDIggaJpZM4PMFDT.
✘ crypdick@pito ~ convert -background "#00000080" -fill white -gravity center -size 1024 -font "Arial" -pointsize 22 caption:"test title" /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg +swap -gravity south -composite /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg
convert: unable to read font `Arial' @ warning/annotate.c/RenderType/964.
convert: unable to read font `Arial' @ error/annotate.c/RenderFreetype/1362.
convert: unable to read font `Arial' @ warning/annotate.c/RenderType/964.
convert: unable to read font `Arial' @ error/annotate.c/RenderFreetype/1362.
convert: no such image `/home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined `/home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/convert.c/ConvertImageCommand/3258.
✘ crypdick@pito ~ ls /home/crypdick/Pictures/Bing
bing_wallpaper_17121.jpg bing_wallpaper_21110.jpg
crypdick@pito ~
I checked the jpegs, there is nothing wrong with them.
Dear Richard:
Can you confirm that the following works flawlessly, please?
convert /home/crypdick/Pictures/bing/bing_wallpaper_17121.jpg -fill white -box "#00000080" -gravity South -pointsize 22 -size 1024 -annotate +0+0 " test title1 " /home/crypdick/Pictures/bing/bing_wallpaper_17121.jpg
Cheers,
Dani
From: Richard Decal [email protected] Sent: Friday, 15 September 2017 12:59 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
✘ crypdick@pito ~ convert -background "#00000080" -fill white -gravity center -size 1024 -font "Arial" -pointsize 22 caption:"test title" /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg +swap -gravity south -composite /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg
convert: unable to read font Arial' @ warning/annotate.c/RenderType/964. convert: unable to read font Arial' @ error/annotate.c/RenderFreetype/1362. convert: unable to read font Arial' @ warning/annotate.c/RenderType/964. convert: unable to read font Arial'
@ error/annotate.c/RenderFreetype/1362. convert: no such image /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/mogrify.c/MogrifyImageList/8775. convert: no images defined /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/convert.c/ConvertImageCommand/3258.
✘ crypdick@pito ~ ls /home/crypdick/Pictures/Bing bing_wallpaper_17121.jpg bing_wallpaper_21110.jpg crypdick@pito ~
I checked the jpegs, there is nothing wrong with them.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-329509671, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM3IfKQZNLMW98mcZPBLbx7jsl1fgks5siT9PgaJpZM4PMFDT.
crypdick@pito ~ convert /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg -fill white -box "#00000080" -gravity South -pointsize 22 -size 1024 -annotate +0+0 " test title1 " /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg
convert: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362.
Hi Richard:
What is the output of #convert -version ?
Cheers,
Dani
From: Richard Decal [email protected] Sent: Friday, 15 September 2017 5:47 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
convert: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362.```
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-329589474, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM2nvsjVYn7ubJr7mZCtxtD9DPSoGks5siYLjgaJpZM4PMFDT.
✘ crypdick@pito ~/Apps/tools master convert -version
Version: ImageMagick 6.9.9-11 Q16 x86_64 2017-09-03 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps rsvg tiff webp wmf x xml zlib
Dear Richard:
Your version of imagemagick is newer than my version. An old version of imagemagick is thus not the issue here. Let me proceed with mogrify. I assume that mogrify has the same issue as convert. Can you run
mogrify /home/crypdick/Pictures/bing/bing_wallpaper_17121.jpg -box "#00000080" -fill white -gravity south -pointsize 22 -size 1024 -annotate +0+0 " experimental title " /home/crypdick/Pictures/bing/bing_wallpaper_17121.jpg
and let me know the output, please?
Cheers,
Dani
From: Richard Decal [email protected] Sent: Friday, 15 September 2017 7:02 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19) ✘ crypdick@pito ~/Apps/tools master convert -version Version: ImageMagick 6.9.9-11 Q16 x86_64 2017-09-03 http://www.imagemagick.org Copyright: © 1999-2017 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Features: Cipher DPC HDRI Modules OpenCL OpenMP Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps rsvg tiff webp wmf x xml zlib — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread. https://github.com/notifications/beacon/ALJSMzPtma_wFqLDHZr7eqN3HpYc8_Nnks5siZRRgaJpZM4PMFDT.gif
mogrify: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362
Dear Richard:
Sources on the internet point to ghostscript as the culprit. Please run
gs -version
and post the output.
Cheers,
Dani
From: Richard Decal [email protected] Sent: Saturday, 16 September 2017 5:39 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
mogrify: unable to read font `(null)' @ error/annotate.c/RenderFreetype/1362
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-329880065, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM0mIQygQh8QXGHb-Zy5Kjz4tEtm8ks5sitJjgaJpZM4PMFDT.
crypdick@pito ~ gs -version
GPL Ghostscript 9.21 (2017-03-16)
Copyright (C) 2017 Artifex Software, Inc. All rights reserved.
Dear Richard:
This should rule out ghostscript as the culprit. Can you run
convert -list fonts
and post the output, please?
Cheers,
Dani
From: Richard Decal [email protected] Sent: Thursday, 14 September 2017 12:10 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
I made it through fine ^_^ I ran this script twice. Both times, it downloaded the photo of the day and saved it using a different filename (don't know if that's intended behavior) but this time my wallpaper did not get replaced.
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
convert: unable to read font (null)' @ error/annotate.c/RenderFreetype/1362. convert: no such image /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/mogrify.c/MogrifyImageList/8775.
convert: no images defined /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg' @ error/convert.c/ConvertImageCommand/3258. ✘ crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh convert: unable to read font (null)' @ error/annotate.c/RenderFreetype/1362.
convert: no such image /home/crypdick/Pictures/Bing/bing_wallpaper_21110.jpg' @ error/mogrify.c/MogrifyImageList/8775. convert: no images defined /home/crypdick/Pictures/Bing/bing_wallpaper_21110.jpg' @ error/convert.c/ConvertImageCommand/3258.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-329179382, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSM0psbumrQK_X0-7hMcSFVqty9J9Oks5sh-HigaJpZM4PMFDT.
Ah, it sounds like we're getting close.
crypdick@pito ~ convert -list fonts
convert: unrecognized list type `fonts' @ error/convert.c/ConvertImageCommand/2053.
Dear Richard:
Can you run
convert -list font
with no s at the end and post the output, please?
Cheers,
Dani
From: Richard Decal [email protected] Sent: Monday, 18 September 2017 12:16 AM To: marguerite/linux-bing-wallpaper Cc: dzmanto; Mention Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Ah, it sounds like we're getting close.
crypdick@pito ~ convert -list fonts convert: unrecognized list type `fonts' @ error/convert.c/ConvertImageCommand/2053.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/marguerite/linux-bing-wallpaper/issues/19#issuecomment-330049747, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALJSMzKT3S_WMtwlhQ-ZFHz18EL1OOnwks5sjSmkgaJpZM4PMFDT.