Git Product home page Git Product logo

weatherdesk's Introduction

WeatherDesk has moved!

Now at GitLab!

WeatherDesk

Change the wallpaper based on the weather and (optionally) the time.

WeatherDesk

Thanks to Martin Hansen for the original Desktop.py module.

Powered by Yahoo!

Installation

Just download the repository, get some wallpapers (see the Wallpapers section) and run the WeatherDesk.py script.

NOTE: If you use OS X, see the note for OS X users.

Options

$ python3 WeatherDesk.py --help
usage: WeatherDesk.py [-h] [-d directory] [-f format] [-w seconds]
                      [-t [{2,3,4}]] [-n] [--no-weather] [-c name [name ...]]
                      [-o]

WeatherDesk - Change the wallpaper based on the weather
        (Uses the Yahoo! Weather API)

optional arguments:
  -h, --help            show this help message and exit
  -d directory, --dir directory
                        Specify wallpaper directory. Default: ~/.weatherdesk_walls
  -f format, --format format
                        Specify image file format. Default: .jpg
  -w seconds, --wait seconds
                        Specify time (in seconds) to wait before updating. Default: 600
  -t [{2,3,4}], --time [{2,3,4}]
                        Use different backgrounds for different times.

                            Variations:
                              2 = day/night
                              3 = day/evening/night [Default]
                              4 = morning/day/evening/night

                            See --naming.
  -n, --naming          Show the image file-naming rules and exit.
  --no-weather          Disable the weather functionality of the script. Wallpapers will only be changed based on the time of day.With this option, no internet connection is required.
  -c name [name ...], --city name [name ...]
                        Specify city for weather. If not given, taken from ipinfo.io.
  -o, --one-time-run    Run once, then exit.

Wallpapers

You can choose your own custom set, conforming to the naming rules. Either put them in the default ~/.weatherdesk_walls/ directory or specify a directory with the --dir option.

Ready-to-Go wallpaper set

Don't want to go hunting for wallpapers? I recommend this beautiful set (called FireWatch, named after a game) (download the set using the ZIP file link given below) made by redditor JuniorNeves.

A zip download of the FireWatch set, named according to the rules: ZIP download. Just extract it into ~/.weatherdesk_walls (or into any directory and pass its path with --dir)

Naming of Pictures

$ python3 WeatherDesk.py --naming
This is how to name files in the wallpaper directory:


       WEATHER           |    FILENAME
_________________________|________________
 Clear, Calm, Fair:      | normal.jpg
 Thunderstorm:           | thunder.jpg
 Windy, Breeze, Gale:    | wind.jpg
 Drizzle, Rain, Showers: | rain.jpg
 Snow:                   | snow.jpg
 Cloudy:                 | cloudy.jpg
 Other:                  | normal.jpg

 If using with --time or --time 3, add:
 "day-", "night-" or "evening-" in front of filename.

 If using with --time 4, add:
 "morning-", "day-", "evening-" or "night-"

 If using with --time 2, add:
 "day-" or "night-"

 If you use --no-weather, the files have to be named simply after the time of day depending of your time schema.
 E.g.: "day.jpg", "night.jpg"

Supported Platforms

  • Linux

    • AfterStep
    • Awesome WM
    • Blackbox
    • Cinnamon
    • Enlightenment
    • Fluxbox
    • Gnome 2
    • Gnome 3
    • i3
    • IceWM
    • JWM
    • KDE
    • LXDE
    • LXQt
    • Mate
    • Openbox
    • Pantheon
    • Razor-Qt
    • Trinity
    • Unity
    • Windowmaker
    • XFCE
  • Windows

  • OS X

In background mode (only for OS X and Linux)

Run

$ nohup python3 WeatherDesk.py > /dev/null &

Note for OS X users

Please disable the auto-reset/change of wallpaper in the "Desktop and Screen Saver" preferences.

Disable this

weatherdesk's People

Contributors

akuederle avatar bharadwaj-raju avatar jcowgill avatar krantideep95 avatar mathdu07 avatar mattread avatar mjprinvale avatar olivervbk avatar tankerkiller125 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

weatherdesk's Issues

Trying to set city - Command not found

I tried:
weatherdesk.py [-c name [Montreal]]
weatherdesk.py : command not found

python3 WeatherDesk.py [-c name [Montreal]]
python3: can't open file 'WeatherDesk.py': [Errno 2] No such file or directory

cant run script

sudo python3 WeatherDesk.py --city chisinau
[City checking] No error.
mostly clear
Chisinau Chisinau
/home/myname/.weatherdesk_walls/normal.jpg
Traceback (most recent call last):
File "WeatherDesk.py", line 379, in
os.path.join(walls_dir, get_file_name(weather, time=use_time)))
File "/home/myname/Desktop/WeatherDesk-master/Desktop.py", line 104, in set_wallpaper
desktop_env = get_desktop_environment()
File "/home/myname/Desktop/WeatherDesk-master/Desktop.py", line 79, in get_desktop_environment
elif is_running('xfce-mcs-manage'): return 'xfce4'
File "/home/myname/Desktop/WeatherDesk-master/Desktop.py", line 96, in is_running
if re.search(process, x):
File "/usr/lib/python3.5/re.py", line 173, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "WeatherDesk.py", line 399, in
print(trace_main_loop)
NameError: name 'trace_main_loop' is not defined

Default wallpapers library

I think you should add default wallpapers library so it is easier to try the software - run it and it works.
Now I see that I have to find wallpapers, rename them and then try it.

Applescript doesn't like single quotes

Minor fix for OS X errors, replacing single quotes with double quotes, and removing "to":

Desktop.py, lines 270-274:

                OSX_SCRIPT = '''tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
                ''' % image

Error on Linux Xfce4

I got an error while using your script in my Xfce4 desktop environment. See below:

[Main loop] 
Traceback (most recent call last):
  File "WeatherDesk.py", line 419, in <module>
    main()
  File "WeatherDesk.py", line 406, in main
    os.path.join(walls_dir, get_file_name(weather, time=use_time)))
  File "/home/xek6ae/WeatherDesk/Desktop.py", line 203, in set_wallpaper
    for i in list_of_properties.subprocesslit('\n'):
AttributeError: 'str' object has no attribute 'subprocesslist'

I change the line 203 of Dektop.py for i in list_of_properties.split('\n'): an then the script works fine for me.

os.path.absubprocessath call

Hi.

In Desktop.py there are 3 instances of a weird "os.path.absubprocessath" call.
I guess it should be os.path.abspath and some search/replace has been a bit zealous.

I dont know how.

Hello my name is jakub Veselovský. can somebody help how to install this? (Windows)

OS X Mavericks: Syntax error

Problem

% cat ~/.weatherdesk_script.AppleScript
tell application 'Finder'
set desktop picture to POSIX file "/Users/sli/Pictures/FireWatch-WeatherDesk-Pack-master/normal.jpg"
end tell
% osascript ~/.weatherdesk_script.AppleScript
17:18: syntax error: Expected expression, property or key form, etc. but found unknown token. (-2741)

Solution

Replace ' with "

% cat ~/.weatherdesk_script.AppleScript | sed s/\'/\"/g                   
tell application "Finder"
set desktop picture to POSIX file "/Users/sli/Pictures/FireWatch-WeatherDesk-Pack-master/normal.jpg"
end tell
% cat ~/.weatherdesk_script.AppleScript | sed s/\'/\"/g | osascript
% echo $?
0

Windows Support

The readme says that it supports windows, but it seems that it is not updating the wall paper, (windows 10) looking at the Desktop.py it seems as if its looking for some .bat file after it runs the rundll3d.exe line but that .bat file doesn't exist.

Gives error on invalid city (SSL error?)

Hi

I've just downloaded this repository to give it a test run.
But when executing the WeatherDesk.py script, I get the following error:

image

I'm not a python dev so I'm not able to figure out what's wrong here.
Any help is welcome!

Can we give own specified wallpapers ?

We can give own specified wallpapers or we can make the arrangements to have some cool urls to have them once connected to internet to download on the local storage and use it.

[Exception] Doesn't want to run with weather sync on (Ubuntu 20.04 LTS - Wayland)

after running python3 WeatherDesk.py without --no-weather getting this exception [Errno -5] No address associated with hostname

stanley@Smith558-Lenovo:~$ cd WeatherDesk-master/
stanley@Smith558-Lenovo:~/WeatherDesk-master$ python3 WeatherDesk.py --time 4
[Main loop] 
Traceback (most recent call last):
  File "/usr/lib/python3.8/urllib/request.py", line 1326, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.8/http/client.py", line 1240, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1286, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1235, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1006, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 946, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 1402, in connect
    super().connect()
  File "/usr/lib/python3.8/http/client.py", line 917, in connect
    self.sock = self._create_connection(
  File "/usr/lib/python3.8/socket.py", line 787, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "WeatherDesk.py", line 356, in <module>
    set_conditional_wallpaper(parsed_args['city'],
  File "WeatherDesk.py", line 305, in set_conditional_wallpaper
    weather, actual_city = get_current_weather(city)
  File "WeatherDesk.py", line 294, in get_current_weather
    weather_json = json.loads(urlopen(weather_json_url).read().decode('utf-8'))['query']['results']['channel']
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.8/urllib/request.py", line 542, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 1369, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/usr/lib/python3.8/urllib/request.py", line 1329, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -5] No address associated with hostname>

/bin/sh: 1: 4: not found

Use /dev/shm/somedir or /tmp/somefile for KDE >4

As you may be aware, directly setting a custom wallpaper for KDE isn't really possible at the moment because the api is not exposed for security reasons.

However this can mitigated by asking the user to point kde's desktop slideshow at a designated folder with a smallish timeout (say, 4 seconds). The trick I have found is to have exactly one file with a randomized filename in a folder. On each wallpaper change, generate a new random name and move the new file in with it, and then delete the old file. It will work most of the time because collisions are very rare.

Example here, line 164-173 at https://github.com/cmdrkotori/qt314wall/blob/master/main.cpp#L164

Not working after suspend/resume

After I suspend and resume my laptop, WeatherDesk stops working. I get the following error on the first run after resume:

[Main loop]
Traceback (most recent call last):
  File "/usr/lib/python3.5/urllib/request.py", line 1240, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.5/http/client.py", line 1083, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1128, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1079, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 911, in _send_output
    self.send(msg)
  File "/usr/lib/python3.5/http/client.py", line 854, in send
    self.connect()
  File "/usr/lib/python3.5/http/client.py", line 1229, in connect
    super().connect()
  File "/usr/lib/python3.5/http/client.py", line 826, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.5/socket.py", line 693, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "WeatherDesk/WeatherDesk.py", line 367, in <module>
    weather_json = json.loads(urlopen(weather_json_url).read().decode('utf-8'))
  File "/usr/lib/python3.5/urllib/request.py", line 162, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 465, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 483, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 443, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1283, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.5/urllib/request.py", line 1242, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

I'm running Python 3.5.1 on Arch Linux.

TypeError: 'NoneType' object is not subscriptable

To put it in simple terms it crashes.

In more detail, first it didn't have a needed dependency for the file psutil, that I solved by running sudo apt install python3-psutil.

But now it crashes with the following:

[City checking] No error.
[Main loop] 
Traceback (most recent call last):
  File "WeatherDesk.py", line 396, in <module>
    weather = str(weather_json['query']['results']['channel']['item']['condition']['text']).lower()
TypeError: 'NoneType' object is not subscriptable

Indentation error

python3 WeatherDesk.py --help

Traceback (most recent call last):
File "WeatherDesk.py", line 14, in
import Desktop
File "/home/mizi/Programmi/WeatherDesk/Desktop.py", line 157
old_working_dir = os.getcwd()
^
IndentationError: unexpected indent

UnicodeEncodeError if your city have non ascii character

Hello,

Thx for python script :)

I am currently in Saint-lô, and your script fail because i have non ascii character in my city.

[Main loop] 
Traceback (most recent call last):
  File "WeatherDesk.py", line 377, in <module>
    main()
  File "WeatherDesk.py", line 350, in main
    print(urlopen(weather_json_url))
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1250, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python3.6/http/client.py", line 1117, in putrequest
    self._output(request.encode('ascii'))
UnicodeEncodeError: 'ascii' codec can't encode character '\xf4' in position 147: ordinal not in range(128)

I have fixed WeatherDesk.py by importing urllib.parse.

...
import urllib.parse
...

def main():
	weather_json_url = r'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22' + urllib.parse.quote(city) + '%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys'
	weather_json = json.loads(urlopen(weather_json_url).read().decode('utf-8'))

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.