Giter VIP home page Giter VIP logo

google-trend-wallpaper's Introduction

Google-Trend-Wallpaper

A python and shell script to set the wallpaper to a wordcloud of the most trending google searches.

This project is inspired from process-wallpaper. You can check it out for the wordcloud of most resource hungry processes running in your system.

Screenshot

Dependencies

  • python3
  • gsettings or feh To set the generated wordcloud as the wallpaper
  • xvfb To simulate a display and run everything in memory
  • firefox web browser

Python dependencies

pip install -r requirements.txt
  • selenium To scrape the data from Google trends
  • pyvirtualdisplay Python wrapper for xvfb
  • wordcloud To generate the wordcloud
  • PIL Python imaging library

NOTE You will need to download the webdriver for selenium. Geckodriver (webdriver for firefox) can be downloaded from here.

Setup

  • Clone this repo
git clone https://github.com/shardul08/Google-Trend-Wallpaper.git
  • Change directory to the repo
cd Google-Trend-Wallpaper
  • Run setup.sh with
./setup.sh

This will install all the required dependencies and set the wallpaper.

Usage

Run ./updateWallpaper.sh to update the wallpaper to the wordcloud of the latest trends.

You can set your region/country to get the trending searches in line #30 of generateWallpaper.py

You can set the number of days for which you want the trending searches in line #31 of generateWallpaper.py

NOTE If the wallpaper is not set automatically, you can set wallpaper.png as the wallpaper manually.

If you want the wallpaper to refresh/update every hour, you can add a cron job to run the script every hour.

To add a cron job, run

crontab -e

append the following

0 * * * * cd path/to/script/directory && ./updateWallpaper.sh > /tmp/wallpaper.log > 2>&1

This will refresh the wallpaper every hour. You can customize this command to refresh the wallpaper as often you want.

If you want adjust the brightness of the wallpaper you can use the dim or brighten commands:

./setBrightness.sh dim|brighten XX

Where XX is the percentage you would like to dim or brighten the image. For example ./setBrightness.sh dim 20 would dim the current wallpaper by 20% and then set the new image as your background. Again you can set wallpaper.png manually if it fails to do it automatically.

google-trend-wallpaper's People

Contributors

gableroux avatar shardul08 avatar sudoursa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

google-trend-wallpaper's Issues

enhancement to dim the wallpaper

generated wallpapers can be an eyesore behind desktops with lots of icons. a dimming option, such as adding a gray transparent layer on top might make them more useful.

Support for multiple monitors

If working on a dual monitor setup, the script considers two screens as one, resulting in a wallpaper that spreads on both screens. an option to set wallpaper on both monitors seperately, or on just one of them would be nice.

setup: "FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'"

With geckodriver not yet installed, I got the hard core error below.

So why not put a try-except around browser = webdriver.Firefox() and exit on an except.

I can send a PR if you want.

sander@witte:~/git/Google-Trend-Wallpaper$ ./setup.sh
Installing Python dependencies...
install ok installed
Installing Pillow...
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (5.4.1)
Creating wallpaper...
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "generateWallpaper.py", line 11, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
    self.service.start()
  File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py", line 83, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

Setting wallpaper...
/usr/bin/gsettings
Setup successfully completed
sander@witte:~/git/Google-Trend-Wallpaper$

setup: ModuleNotFoundError: No module named 'pyvirtualdisplay'

See below. Why not let setup do the pip install pyvirtualdisplay ?

Installing Python dependencies...
install ok installed
Installing Pillow...
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (5.4.1)
Installing pyvirtualdisplay...
Requirement already satisfied: matplotlib in /home/sander/.local/lib/python3.7/site-packages (3.1.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (2.4.2)
Requirement already satisfied: cycler>=0.10 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /usr/lib/python3/dist-packages (from matplotlib) (2.7.3)
Requirement already satisfied: numpy>=1.11 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (1.17.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from cycler>=0.10->matplotlib) (1.12.0)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from kiwisolver>=1.0.1->matplotlib) (41.1.0)
Creating wallpaper...
Traceback (most recent call last):
  File "generateWallpaper.py", line 2, in <module>
    from pyvirtualdisplay import Display
ModuleNotFoundError: No module named 'pyvirtualdisplay'
Setting wallpaper...
/usr/bin/gsettings
Setup successfully completed

solution:

sander@witte:~/git/Google-Trend-Wallpaper$ sudo pip3 install pyvirtualdisplay
WARNING: The directory '/home/sander/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/sander/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyvirtualdisplay
  Downloading https://files.pythonhosted.org/packages/cf/ad/b15f252bfb0f1693ad3150b55a44a674f3cba711cacdbb9ae2f03f143d19/PyVirtualDisplay-0.2.4-py2.py3-none-any.whl
Collecting EasyProcess (from pyvirtualdisplay)
  Downloading https://files.pythonhosted.org/packages/fa/29/40040d1d64a224a5e44df9572794a66494618ffe5c77199214aeceedb8a7/EasyProcess-0.2.7-py2.py3-none-any.whl
Installing collected packages: EasyProcess, pyvirtualdisplay
Successfully installed EasyProcess-0.2.7 pyvirtualdisplay-0.2.4
sander@witte:~/git/Google-Trend-Wallpaper$ 

Setting Country to PK fails

ISO 3166 country codes for India and Canada work, fails for Pakistan with:

$ ./updateWallpaper.sh 
Creating wallpaper...
Traceback (most recent call last):
  File "generateWallpaper.py", line 23, in <module>
    link_div = browser.find_element_by_xpath("/html/body/div[2]/div[2]/div/div[2]/div/div[{}]".format(k))
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 394, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 978, in find_element
    'value': value})['value']
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /html/body/div[2]/div[2]/div/div[2]/div/div[2]

Setting wallpaper...
/usr/bin/gsettings

Fails on Arch linux

$ ./updateWallpaper.sh 
Creating wallpaper...
Traceback (most recent call last):
  File "generateWallpaper.py", line 11, in <module>
    browser = webdriver.Firefox()
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities

Setting wallpaper...
/usr/bin/gsettings

geckodriver not detected on Mac OS

Hello, I have troubles to get it working on Mojave. I installed geckodriver yet I am still getting errors. With sudo and without sudo, same:

janbenes@Jans-Mac ~/Google-Trend-Wallpaper> brew install geckodriver
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/geckodriver-0.24.0.mojave.bottle.tar.gz
Already downloaded: /Users/janbenes/Library/Caches/Homebrew/downloads/8ab92ea1151f5b108dc35c68f6fe616f20414cf6ab7099e42f58b8dbfb169b6a--geckodriver-0.24.0.mojave.bottle.tar.gz
==> Pouring geckodriver-0.24.0.mojave.bottle.tar.gz
๐Ÿบ /usr/local/Cellar/geckodriver/0.24.0: 7 files, 5.9MB
janbenes@Jans-Mac ~/Google-Trend-Wallpaper> sudo ./updateWallpaper.sh
Creating wallpaper...
ERROR: Install geckodriver, and make sure it's in your PATH
Something went wrong
You can raise an issue at https://github.com/shardul08/Google-Trend-Wallpaper/issues

setup: ModuleNotFoundError: No module named 'selenium'

With setup.sh, I get ModuleNotFoundError: No module named 'selenium'.

Solved with sudo pip install selenium ... so why doesn't the setup.sh do that?

$ ./setup.sh
Installing Python dependencies...
install ok installed
Installing Pillow...
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (5.4.1)
Installing selenium...
Requirement already satisfied: matplotlib in /home/sander/.local/lib/python3.7/site-packages (3.1.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/lib/python3/dist-packages (from matplotlib) (2.7.3)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: numpy>=1.11 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (1.17.1)
Requirement already satisfied: cycler>=0.10 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (2.4.2)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from kiwisolver>=1.0.1->matplotlib) (41.1.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from cycler>=0.10->matplotlib) (1.12.0)
Installing pyvirtualdisplay...
Requirement already satisfied: matplotlib in /home/sander/.local/lib/python3.7/site-packages (3.1.1)
Requirement already satisfied: numpy>=1.11 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (1.17.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (1.1.0)
Requirement already satisfied: cycler>=0.10 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/sander/.local/lib/python3.7/site-packages (from matplotlib) (2.4.2)
Requirement already satisfied: python-dateutil>=2.1 in /usr/lib/python3/dist-packages (from matplotlib) (2.7.3)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/dist-packages (from kiwisolver>=1.0.1->matplotlib) (41.1.0)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from cycler>=0.10->matplotlib) (1.12.0)
Creating wallpaper...
Traceback (most recent call last):
  File "generateWallpaper.py", line 1, in <module>
    from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Setting wallpaper...
/usr/bin/gsettings
Setup successfully completed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.