-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work with zsh #19
Comments
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-L44<https://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 GitHub<#19>, or mute the thread<https://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-L44<https://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 GitHub<#19>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSMwFa-F10pOF5qKRfKRFVBhq0Ah1jks5sfB6hgaJpZM4PMFDT>.
|
Thanks for your quick response! Here's the output:
|
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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM8Ucp1NQWNPn5hoHGfZIoRgWy0ggks5sfdTxgaJpZM4PMFDT>.
|
|
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)
@dzmanto<https://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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM51CfkfB2I-tL2WnnNc67Fe7PrASks5sfozrgaJpZM4PMFDT>.
|
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 GitHub<#19 (comment)>, or mute the thread<https://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 🥇 |
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 "<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 "Nimbus 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: 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.
|
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 GitHub<#19 (comment)>, or mute the thread<https://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 GitHub<#19 (comment)>, or mute the thread<https://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.
|
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 GitHub<#19 (comment)>, or mute the thread<https://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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM_TCoE-W-BUPe3sSV4SaGOhdV2geks5siDIggaJpZM4PMFDT>.
|
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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM3IfKQZNLMW98mcZPBLbx7jsl1fgks5siT9PgaJpZM4PMFDT>.
|
|
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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM2nvsjVYn7ubJr7mZCtxtD9DPSoGks5siYLjgaJpZM4PMFDT>.
|
|
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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM0mIQygQh8QXGHb-Zy5Kjz4tEtm8ks5sitJjgaJpZM4PMFDT>.
|
|
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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM0psbumrQK_X0-7hMcSFVqty9J9Oks5sh-HigaJpZM4PMFDT>.
|
Ah, it sounds like we're getting close.
|
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 GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSMzKT3S_WMtwlhQ-ZFHz18EL1OOnwks5sjSmkgaJpZM4PMFDT>.
|
I posted the output here: https://gist.github.com/crypdick/966660788d13d9a8941fd49d17e06148 |
Hi Richard:
Please try
convert /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg -fill white -box "#00000080" -gravity South -font "Bitstream-Vera-Sans" -pointsize 22 -annotate +0+5 " this is an experimental title " /home/crypdick/Pictures/Bing/bing_wallpaper_17121.jpg
and keep me posted.
Cheers,
Dani
From: Richard Decal <[email protected]>
Sent: Monday, 18 September 2017 6:26 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
I posted the output here: https://gist.github.com/crypdick/966660788d13d9a8941fd49d17e06148
—
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/ALJSMx-QYp57VsBm4Bh5THAvhha9t1XLks5sjYCCgaJpZM4PMFDT.gif
|
Dear Richard:
I was ill for a few days. I now find time to finalize bing_wallpaper.sh.
Can you run the enclosed script and let me know if it displays wallpapers with annotations, please?
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/dzmanto/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 )
/usr/bin/convert "$tfn" -resize 1920x1200 "$tfn"
iswc=$(which wc)
if [ -x $iswc ]; then
isBitStream=$(/usr/bin/convert -list font | grep "Bitstream-Vera-Sans" | wc -l)
isDejaVu=$(/usr/bin/convert -list font | grep "DejaVu-Sans" | wc -l)
if [ $isBitStream -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "Bitstream-Vera-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity south -composite "$tfn"
elif [ $isDejaVu -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "DejaVu-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity south -composite "$tfn"
fi
fi
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, 19 September 2017 6:58 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Success!
https://user-images.githubusercontent.com/5415776/30564313-9b73340e-9c92-11e7-9b61-99a04db8633c.jpg https://user-images.githubusercontent.com/5415776/30564313-9b73340e-9c92-11e7-9b61-99a04db8633c.jpg
—
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/ALJSM0sOz4aLVmrnM2voQRPT8qocj1Vxks5sjtmDgaJpZM4PMFDT.gif
|
Hmm. It updated my background without any errors, but I don't see any text. Edit: I wonder if it's just that the text is being covered by my taskbar. What line should I edit to make the title print in the center of the image? |
Hi Richard:
Can you forward the output of the below script, please?
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/dzmanto/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 )
/usr/bin/convert "$tfn" -resize 1920x1200 "$tfn"
iswc=$(which wc)
echo $iswc
if [ -x $iswc ]; then
isBitStream=$(/usr/bin/convert -list font | grep "Bitstream-Vera-Sans" | wc -l)
echo $isBitStream
isDejaVu=$(/usr/bin/convert -list font | grep "DejaVu-Sans" | wc -l)
echo $isDejaVu
if [ $isBitStream -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "Bitstream-Vera-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity south -composite "$tfn"
elif [ $isDejaVu -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "DejaVu-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity south -composite "$tfn"
fi
fi
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: Friday, 22 September 2017 12:45 PM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Hmm. It updated my background without any errors, but I don't see any text.
—
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/ALJSM8IAo9WNPVG3ahbA4SsxQq2YvSLkks5skx85gaJpZM4PMFDT.gif
|
|
Dear Richard:
Can you open your background image with eog, gimp or similar and check if there is annotation at the bottom of the image, please? I suspect that whatever desktop you're using hides the bottom portion of your wallpaper image.
If gimp or eog do not show annotation, please run the enclosed script with extra diagnostic information and let me know the result, please.
Cheers,
Daniela
From: Richard Decal <[email protected]>
Sent: Saturday, 23 September 2017 4:37 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh /usr/bin/wc 8 17 —
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/ALJSMx5K2xoCm05-Ja848fGLrI-hbfNEks5sk_5PgaJpZM4PMFDT.gif
|
Hmm. They don't seem to be in `/home/crypdick/Pictures/Bing` anymore. Any
ideas?
Richard Decal
…On Fri, Sep 22, 2017 at 3:15 PM, dzmanto ***@***.***> wrote:
Dear Richard:
Can you open your background image with eog, gimp or similar and check if
there is annotation at the bottom of the image, please? I suspect that
whatever desktop you're using hides the bottom portion of your wallpaper
image.
If gimp or eog do not show annotation, please run the enclosed script with
extra diagnostic information and let me know the result, please.
Cheers,
Daniela
From: Richard Decal ***@***.***>
Sent: Saturday, 23 September 2017 4:37 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh
(#19)
***@***.*** ~/Apps/bing-desktop-wallpaper-changer master sh
bing_wallpaper.sh /usr/bin/wc 8 17 —
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/ALJSMx5K2xoCm05-Ja848fGLrI-
hbfNEks5sk_5PgaJpZM4PMFDT.gif
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFKjYDRrzfw-_1oCAVu-ibMe2nOlGypSks5slAdSgaJpZM4PMFDT>
.
|
Dear Richard:
You wallpaper picture is in /tmp/bing_wallpaper_xxxx.jpg
Just go for the latest picture. Is it annotated?
Cheers,
Daniela
________________________________
From: Richard Decal <[email protected]>
Sent: Saturday, 23 September 2017 5:45 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Hmm. They don't seem to be in `/home/crypdick/Pictures/Bing` anymore. Any
ideas?
Richard Decal
On Fri, Sep 22, 2017 at 3:15 PM, dzmanto ***@***.***> wrote:
Dear Richard:
Can you open your background image with eog, gimp or similar and check if
there is annotation at the bottom of the image, please? I suspect that
whatever desktop you're using hides the bottom portion of your wallpaper
image.
If gimp or eog do not show annotation, please run the enclosed script with
extra diagnostic information and let me know the result, please.
Cheers,
Daniela
From: Richard Decal ***@***.***>
Sent: Saturday, 23 September 2017 4:37 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh
(#19)
***@***.*** ~/Apps/bing-desktop-wallpaper-changer master sh
bing_wallpaper.sh /usr/bin/wc 8 17 —
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/ALJSMx5K2xoCm05-Ja848fGLrI-
hbfNEks5sk_5PgaJpZM4PMFDT.gif
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFKjYDRrzfw-_1oCAVu-ibMe2nOlGypSks5slAdSgaJpZM4PMFDT>
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSM8bFTVQXBx1i91PQdCfZMiXG0xnXks5slA5ygaJpZM4PMFDT>.
|
Ah yes! They are properly annotated! |
Hi Richard:
Can you post the output of
# uname -a
please?
Cheers,
Daniela
From: Richard Decal <[email protected]>
Sent: Sunday, 24 September 2017 12:07 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Ah yes! They are properly annotated!
—
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/ALJSM_iR5xoc2cMXEJydlzp8-io1bgPhks5slRC6gaJpZM4PMFDT.gif
|
|
Dear Richard:
I should also detect your desktop environment to get to the bottom of this issue.
What the output of the below check script, please?
Cheers,
Daniela
…--
# 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/dzmanto/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
}
DE=$(detectDE)
echo $DE
From: Richard Decal <[email protected]>
Sent: Monday, 25 September 2017 5:33 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Linux pito 4.9.51-1-MANJARO #1 SMP PREEMPT Wed Sep 20 10:37:40 UTC 2017 x86_64 GNU/Linux
—
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/ALJSM9o9h2WliZVNxniUy45TGC9CqngLks5slq6cgaJpZM4PMFDT.gif
|
The output is "WM". My actual environment is i3wm. |
Hi Richard:
The enclosed script should fix the annotation problem. Can you post its output, please?
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/dzmanto/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 )
/usr/bin/convert "$tfn" -resize 1920x1200 "$tfn"
if [ "$DE" = "WM" ]; then
grav="north"
else
grav="south"
fi
echo $grav
iswc=$(which wc)
if [ -x $iswc ]; then
isBitStream=$(/usr/bin/convert -list font | grep "Bitstream-Vera-Sans" | wc -l)
isDejaVu=$(/usr/bin/convert -list font | grep "DejaVu-Sans" | wc -l)
if [ $isBitStream -ge 1 ]; then
echo "bitstream annotating background image"
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "Bitstream-Vera-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "$grav" -composite "$tfn"
elif [ $isDejaVu -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "DejaVu-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "$grav" -composite "$tfn"
fi
fi
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-fill --no-fehbg "$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, 26 September 2017 12:32 PM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
The output is "WM"
—
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/ALJSM2s1INJmI3_zKmbSOb9PYUDcmIWgks5smGItgaJpZM4PMFDT.gif
|
Output:
No annotation on the wallpaper fyi. |
Hi Richard,
does the below script deliver annotation and what is the output, please?
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/dzmanto/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 )
/usr/bin/convert "$tfn" -resize 1920x1200 "$tfn"
echo $DE
if [ "$DE" = "WM" ]; then
grav="north"
else
grav="south"
fi
echo $grav
iswc=$(which wc)
if [ -x $iswc ]; then
isBitStream=$(/usr/bin/convert -list font | grep "Bitstream-Vera-Sans" | wc -l)
isDejaVu=$(/usr/bin/convert -list font | grep "DejaVu-Sans" | wc -l)
if [ $isBitStream -ge 1 ]; then
echo "bitstream annotating background image"
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "Bitstream-Vera-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity -composite "$tfn"
elif [ $isDejaVu -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "DejaVu-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "$grav" -composite "$tfn"
fi
fi
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-fill --no-fehbg "$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: Wednesday, 27 September 2017 2:06 PM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Outpnut:
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh south bitstream annotating background image convert: missing an image filename `south' @ error/convert.c/ConvertImageCommand/3255. bing_wallpaper.sh: line 265: -composite: command not found No annotation on the wallpaper fyi.
—
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/ALJSM06Y-6TSuNpuxnwo7CjWHzrFc-Q3ks5smcnbgaJpZM4PMFDT.gif
|
I inspected the picture in /tmp/ and it did not have an annotation. |
Hi Richard:
I checked the script and found two bugs. Either bug should now be fixed. Can you let me know if the following works and what output it produces, please?
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/dzmanto/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)
DE=$(detectDE)
# 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 )
/usr/bin/convert "$tfn" -resize 1920x1200 "$tfn"
echo $DE
grav="south"
if [ "$DE" = "WM" ]; then
grav="north"
fi
echo $grav
iswc=$(which wc)
if [ -x $iswc ]; then
isBitStream=$(/usr/bin/convert -list font | grep "Bitstream-Vera-Sans" | wc -l)
isDejaVu=$(/usr/bin/convert -list font | grep "DejaVu-Sans" | wc -l)
if [ $isBitStream -ge 1 ]; then
echo "bitstream annotating background image"
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "Bitstream-Vera-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "${grav}" -composite "$tfn"
elif [ $isDejaVu -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "DejaVu-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "${grav}" -composite "$tfn"
fi
fi
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
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-fill --no-fehbg "$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: Friday, 29 September 2017 11:02 PM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh south bitstream annotating background image convert: unrecognized gravity type `-composite' @ error/convert.c/ConvertImageCommand/1721. I inspected the picture in /tmp/ and it did not have an annotation.
—
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/ALJSM8jKY3gUv7dNoHrrn-CJsD_7FL9cks5snOp3gaJpZM4PMFDT.gif
|
No annotation :( Here's the CLI output:
|
Hi Richard:
Maybe there was no internet connection when you ran the script? Can you try the enclosed script again, please?
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/dzmanto/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)
DE=$(detectDE)
# 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 )
/usr/bin/convert "$tfn" -resize 1920x1200 "$tfn"
echo $DE
grav="south"
if [ "$DE" = "WM" ]; then
grav="north"
fi
echo $grav
iswc=$(which wc)
if [ -x $iswc ]; then
isBitStream=$(/usr/bin/convert -list font | grep "Bitstream-Vera-Sans" | wc -l)
isDejaVu=$(/usr/bin/convert -list font | grep "DejaVu-Sans" | wc -l)
if [ $isBitStream -ge 1 ]; then
echo "bitstream annotating background image"
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "Bitstream-Vera-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "$grav" -composite "$tfn"
elif [ $isDejaVu -ge 1 ]; then
/usr/bin/convert -background "#00000080" -fill white -gravity center -size 1024 -font "DejaVu-Sans" -pointsize 22 caption:"${title}" "$tfn" +swap -gravity "$grav" -composite "$tfn"
fi
fi
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
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-fill --no-fehbg "$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: Sunday, 1 October 2017 3:52 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
No output, no annotation :(
—
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/ALJSM8EXNMRA1QkRi9TFPMcRdt9B-vxIks5snnHZgaJpZM4PMFDT.gif
|
Sorry for the delayed response. Somehow the notification was cleared before I saw it. The wallpaper downloaded and was annotated properly 💯
|
Fantastic!
Thank you so much for your feedback.
Cheers,
Dani
…________________________________
From: Richard Decal <[email protected]>
Sent: Saturday, 7 October 2017 3:16 AM
To: marguerite/linux-bing-wallpaper
Cc: dzmanto; Mention
Subject: Re: [marguerite/linux-bing-wallpaper] Does not work with zsh (#19)
Sorry for the delayed response. Somehow the notification was cleared before I saw it. The wallpaper downloaded and was annotated properly 💯
crypdick@pito ~/Apps/bing-desktop-wallpaper-changer master sh bing_wallpaper.sh
WM
north
bitstream annotating background image
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#19 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ALJSMxQB29uHe2KOOfahAqC-Rc5WGrApks5splJDgaJpZM4PMFDT>.
|
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/).The text was updated successfully, but these errors were encountered: