Может кто-нибудь помочь мне с тем, как сделать Bing Picture для обоев рабочего стола?
- Должен ли я написать сценарий? Это будет оценено многими другими! Заранее спасибо :)
Наверное, проще всего будет установить variety. Это менеджер обоев, который действительно делает отличную работу , чтобы изменить ваши обои с той частотой, которую вы хотите.
Вот некоторые из его настроек:
Есть также настройка для запуска его при входе в систему. Если вы включите это и затем добавите ваш bing образ дня url (http://www.bing.com/images/search?q=picture+of+the+day&qpvt=picture+of+the+day&FORM=IGRE
?), то все готово.
Его можно найти в программном центре, и он имеет 5* рейтинг!
Вот несколько скриншотов:
Я написал небольшой скрипт узла, который делает именно это: https://github.com/dorian-marchal/bing-daily-wallpaper
Чтобы установить его, вы ' Мне понадобится nodejs:
sudo apt-get install nodejs npm
Установка:
В командной строке запустите:
sudo npm install -g bing-daily-wallpaper
Использование:
Чтобы изменить обои, выполните (вы можете добавить эту команду в свои запускаемые приложения):
bing-daily-wallpaper
Некоторое время назад я нашёл следующий скрипт (я не помню точно, где именно в этот момент, но когда я его найду, я также добавлю исходный текст), который я немного изменил и который отлично работает, если он установлен как задание cron (смотрите здесь, как это сделать):
#!/bin/bash
# export DBUS_SESSION_BUS_ADDRESS environment variable useful when the script is set as a cron job
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
# $bing is needed to form the fully qualified URL for
# the Bing pic of the day
bing="www.bing.com"
# $xmlURL is needed to get the xml data from which
# the relative URL for the Bing pic of the day is extracted
#
# The mkt parameter determines which Bing market you would like to
# obtain your images from.
# Valid values are: en-US, zh-CN, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA.
#
# The idx parameter determines where to start from. 0 is the current day,
# 1 the previous day, etc.
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=1&n=1&mkt=en-US"
# $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/BingDesktopImages/"
# 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="zoom"
# The desired Bing picture resolution to download
# Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"
desiredPicRes="_1366x768"
# The file extension for the Bing pic
picExt=".jpg"
# 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
# Form the URL for the desired pic resolution
desiredPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$desiredPicRes$picExt
# Form the URL for the default pic resolution
defaultPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<url>(.*)</url>" | cut -d ">" -f 2 | cut -d "<" -f 1)
# $picName contains the filename of the Bing pic of the day
# Attempt to download the desired image resolution. If it doesn't
# exist then download the default image resolution
if wget --quiet --spider "$desiredPicURL"
then
# Set picName to the desired picName
picName=${desiredPicURL##*/}
# Download the Bing pic of the day at desired resolution
curl -s -o $saveDir$picName $desiredPicURL
else
# Set picName to the default picName
picName=${defaultPicURL##*/}
# Download the Bing pic of the day at default resolution
curl -s -o $saveDir$picName $defaultPicURL
fi
# Set the GNOME3 wallpaper
gsettings set org.gnome.desktop.background picture-uri "file://$saveDir$picName"
# Set the GNOME 3 wallpaper picture options
gsettings set org.gnome.desktop.background picture-options $picOpts
# Remove pictures older than 30 days
#find $saveDir -atime 30 -delete
# Exit the script
exit
Хороший сценарий здесь указан, который по-прежнему хорошо работает в Ubuntu 14.04 (требуется установка curl):
http://ubuntuforums.org/showthread.php?t=2074098
, и я скопирую последнюю версию здесь:
#!/bin/bash
# $bing is needed to form the fully qualified URL for
# the Bing pic of the day
bing="www.bing.com"
# $xmlURL is needed to get the xml data from which
# the relative URL for the Bing pic of the day is extracted
#
# The mkt parameter determines which Bing market you would like to
# obtain your images from.
# Valid values are: en-US, zh-CN, ja-JP, en-AU, en-UK, de-DE, en-NZ, en-CA.
#
# The idx parameter determines where to start from. 0 is the current day,
# 1 the previous day, etc.
xmlURL="http://www.bing.com/HPImageArchive.aspx?format=xml&idx=0&n=1&mkt=en-US"
# $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/BingDesktopImages/'
# 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="zoom"
# The desired Bing picture resolution to download
# Valid options: "_1024x768" "_1280x720" "_1366x768" "_1920x1200"
desiredPicRes="_1920x1200"
# The file extension for the Bing pic
picExt=".jpg"
# 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
# Form the URL for the desired pic resolution
desiredPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<urlBase>(.*)</urlBase>" | cut -d ">" -f 2 | cut -d "<" -f 1)$desiredPicRes$picExt
# Form the URL for the default pic resolution
defaultPicURL=$bing$(echo $(curl -s $xmlURL) | grep -oP "<url>(.*)</url>" | cut -d ">" -f 2 | cut -d "<" -f 1)
# $picName contains the filename of the Bing pic of the day
# Attempt to download the desired image resolution. If it doesn't
# exist then download the default image resolution
if wget --quiet --spider "$desiredPicURL"
then
# Set picName to the desired picName
picName=${desiredPicURL##*/}
# Download the Bing pic of the day at desired resolution
curl -s -o $saveDir$picName $desiredPicURL
else
# Set picName to the default picName
picName=${defaultPicURL##*/}
# Download the Bing pic of the day at default resolution
curl -s -o $saveDir$picName $defaultPicURL
fi
# 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
# Exit the script
exit
Я проверил это некоторое время и, похоже, работает.
#!/bin/bash
cd
rm ./dodo.html
wget --no-proxy --output-document=dodo.html http://www.bing.com
rm ./dwallpaper.jpg
wget --no-proxy --output-document=dwallpaper `sed -n "s/^.*g_img *= *{ *url:'\([^']*\)'.*$/\1/p" < dodo.html | sed 's/^"\(.*\)"$/\1/' | sed 's/^\/\(.*\)/http:\/\/www.bing.com\/\1/'`
rm ./dodo.html
gsettings set org.gnome.desktop.background picture-uri 'file:///home/YourName/dwallpaper'
Если вы работаете под прокси, удалите - no-proxy
из строк 4 и 6, и вместо YourName
введите имя вашей домашней папки.
Сохраните это как какой-нибудь скрипт, сделайте его исполняемым и затем запускайте его всякий раз, когда вы хотите, чтобы обои обновлялись.
Я не знаю, как безопасно выполнить это при запуске. Добавив это в rc.local
небезопасен, как я понял из this .
Прокомментируйте, если что-то пойдет не так.
Я искал ответ, но не нашел, поэтому написал сценарий для установки обоев Bing. Вот сценарий ...
#!/bin/sh ping -q -c5 bing.com if [ $? -eq 0 ] then wget "http://www.bing.com/HPImageArchive.aspx?format=rss&idx=0&n=1&mkt=en-US" -O bing.txt img_result=$(grep -o 'src="[^"]*"' bing.txt | grep -o '/.*.jpg') wget "http://www.bing.com"$img_result img_name=$(grep -o 'src="[^"]*"' bing.txt | grep -o '[^/]*.jpg') pwdPath=$(pwd) picPath="/home/YOUR USERNAME/Pictures/Wallpapers" cp $pwdPath"/"$img_name $picPath gsettings set org.gnome.desktop.background picture-uri "file://"$picPath"/"$img_name sleep 10 rm $img_name rm bing.txt fi
Здесь мой инструмент для загрузки новейших обоев из Bing и установки их в качестве обоев рабочего стола. Вы можете проверить это https://github.com/bachvtuan/Bing-Linux-Wallpaper
вы можете использовать bing-wall, работает как обои bing для окон.
вы можете установить его с помощью 'sudo snap install bing-wall'
исходный код находится по адресу