Bing Picture of the Day в качестве рабочего стола?

Может кто-нибудь помочь мне с тем, как сделать Bing Picture на рабочий стол?

Так работает, загружая самое высокое качество сегодняшней картины. Затем сохраните его в папке «Изображение» вашей учетной записи. После этого автоматически меняется сама картинка. Он должен продолжаться каждый день без хлопот на заднем плане. Возможно, что-то, что я должен добавить в приложения для запуска. Любые различия между версиями Ubuntu?

-До мне нужно написать скрипт? Это было бы оценено и многими другими! Спасибо вам, Advance:)

1
задан 19 November 2013 в 20:41

6 ответов

Я написал небольшой скрипт узла, который делает именно это: 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
13
ответ дан 24 May 2018 в 15:05
  • 1
    Nice, это простое решение, которое работает для меня на Ubuntu 15 – Jon Onstott 12 May 2016 в 19:53
  • 2
    Я выполнил вышеуказанные шаги, но получил ошибку при использовании paper96@localhost:~$ bing-daily-wallpaper /usr/bin/env: ‘node’: No such file or directory @Dorian, можете ли вы сказать мне, что не так – Pankaj Gautam 18 December 2016 в 16:45
  • 3
    @PankajGautam, потому что в новых версиях ubuntu, когда вы выполняете apt-get install nodejs, исполняемый файл узла фактически nodejs не node, поэтому, если вы редактируете скрипт sudo vim /usr/local/bin/bing-daily-wallpaper, вы можете заменить первую строку node на nodejs, и это работает хорошо. – stedotmartin 25 May 2017 в 23:54

Некоторое время назад я нашел следующий скрипт (я не помню точно, где в этот момент, но когда я найду, я также добавлю источник), какой из них я немного изменил и который отлично работает для того, что вы спросил, задано ли задание 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
8
ответ дан 24 May 2018 в 15:05

Здесь показан хороший сценарий, который по-прежнему хорошо работает на Ubuntu 14.04 (требуется завиток):

http://ubuntuforums.org/showthread.php?t=2074098

[d3 ], и я скопирую последнюю версию здесь:

#!/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
3
ответ дан 24 May 2018 в 15:05

Я проверил это некоторое время и, кажется, работает.

#!/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/^&quot;\(.*\)&quot;$/\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 небезопасно, как я понимаю из этого.

Прокомментируйте, если что-то пойдет не так.

2
ответ дан 24 May 2018 в 15:05
  • 1
    Если скрипт работает (не проверен), вы можете выполнить его один раз в день (или когда захотите) с помощью задания cron. Посмотрите, например, на askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job – Rmano 7 December 2013 в 13:08
  • 2
    Я думаю, что это было бы необязательно выполнять его более одного раза в день. Кроме того, через день он должен выполняться только один раз, когда устанавливается интернет-соединение. Могут ли работать cron? Можем ли мы узнать, когда будет установлено соединение? – nitishch 7 December 2013 в 19:49
  • 3
    все работы по проверке подключения к Интернету, загрузке изображения, настройке фона рабочего стола и созданию журнала, чтобы указать, должно ли выполняться задание на день или завершить его, должен выполняться вашим сценарием; в то время как cron обрабатывает вызов скрипта в соответствии с вашими потребностями. – precise 6 January 2014 в 23:43
  • 4
    Для лучшей переносимости замените последнюю строку (gsettings set org.gnome.desktop.background picture-uri 'file:///home/YourName/dwallpaper') на gsettings set org.gnome.desktop.background picture-uri ` echo "'file:///home/$USER/dwallpaper'" ` – totti 8 January 2014 в 14:56

Здесь мой мой инструмент для загрузки новейших wallpapapers из Bing и установите его как обои для рабочего стола. Вы можете проверить это https://github.com/bachvtuan/Bing-Linux-Wallpaper

2
ответ дан 24 May 2018 в 15:05
  • 1
    PLease включает в себя как минимум инструкции по установке и использованию в ответе. – muru 5 April 2015 в 12:44
  • 2
    Хотя эта ссылка может ответить на вопрос, лучше включить здесь основные части ответа и предоставить ссылку для справки. Ответные ссылки могут стать недействительными, если связанная страница изменится. – Paranoid Panda 5 April 2015 в 13:14
  • 3
    @ParanoidPanda Это ссылка на исходную страницу. Если он умрет, тогда этот ответ будет недействительным. – Sparhawk 1 March 2016 в 09:38

Я искал ответ, но не нашел, поэтому написал сценарий для установки обоев 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
0
ответ дан 24 May 2018 в 15:05

Другие вопросы по тегам:

Похожие вопросы: