-
Notifications
You must be signed in to change notification settings - Fork 8
/
steam-idle.py
67 lines (59 loc) · 1.84 KB
/
steam-idle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import platform
import io
from PIL import Image, ImageTk
from ctypes import CDLL
try: #Python 2
from urllib2 import urlopen
except ImportError: # Python 3
from urllib.request import urlopen
try:
import Tkinter as tk
except ImportError:
import tkinter as tk
def get_steam_api():
if sys.platform.startswith('linux'):
if platform.architecture()[0].startswith('32bit'):
print('Loading Linux 32bit library')
steam_api = CDLL('./libsteam_api32.so')
elif platform.architecture()[0].startswith('64bit'):
print('Loading Linux 64bit library')
steam_api = CDLL('./libsteam_api64.so')
else:
print('Linux architecture not supported')
else:
print('Operating system not supported')
sys.exit()
return steam_api
def init_gui(str_app_id):
gui = tk.Tk()
gui.title('App ' + str_app_id)
gui.resizable(0, 0)
try:
url = "http://cdn.akamai.steamstatic.com/steam/apps/" + str_app_id + "/header_292x136.jpg"
image_bytes = urlopen(url).read()
data_stream = io.BytesIO(image_bytes)
pil_image = Image.open(data_stream)
tk_image = ImageTk.PhotoImage(pil_image)
label = tk.Label(gui, image = tk_image)
label.image = tk_image
except:
label = tk.Label(gui, text = "Couldn't load image")
label.pack()
return gui
if __name__ == '__main__':
if len(sys.argv) != 2:
print("Wrong number of arguments")
sys.exit()
str_app_id = sys.argv[1]
os.environ["SteamAppId"] = str_app_id
try:
get_steam_api().SteamAPI_Init()
except:
print("Couldn't initialize Steam API")
sys.exit()
gui = init_gui(str_app_id)
gui.mainloop()