-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-linux.py
More file actions
76 lines (57 loc) · 2.36 KB
/
script-linux.py
File metadata and controls
76 lines (57 loc) · 2.36 KB
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
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# -*- coding: utf-8 -*-
import gi
import os
import json
gi.require_version('Gtk', '3.0')
gi.require_version('Notify', '0.7')
from gi.repository import Gtk
from gi.repository import Notify
print("Libs successfully imported !")
sb_dir = \
'/home/gigad/.steam/debian-installation/steamapps/common/Starbound/linux'
#sb_dir = '/home/gigad/Documents/Starbound-master/dist'
instances = '/home/gigad/Documents/instances'
class MyWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title='minimal multibound')
Gtk.Window.set_default_size(self, 640, 480)
Notify.init('Simple GTK3 Application')
self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
self.add(self.box)
self.button = []
i = 0
for file in os.listdir(instances):
d = os.path.join(instances, file)
if os.path.isdir(d):
self.button.append(Gtk.Button(label=file))
#self.button[i].set_halign(Gtk.Align.CENTER)
#self.button[i].set_valign(Gtk.Align.CENTER)
self.button[i].connect('clicked', self.on_button_clicked, d, file)
self.box.pack_start(self.button[i], True, True, 0)
print(d)
i = i +1
self.browse = Gtk.Button(label='browse')
self.browse.set_halign(Gtk.Align.CENTER)
self.browse.set_valign(Gtk.Align.CENTER)
self.browse.connect('clicked', self.open_dir, sb_dir)
self.box.pack_start(self.browse, True, True, 0)
def open_dir(self, widget, *data):
os.system('xdg-open ' + data[0])
def on_button_clicked(self, widget, *data):
n = Notify.Notification.new('Starbound', data[1])
n.show()
os.chdir(sb_dir)
with open(sb_dir + '/sbinit.config', 'r+') as f:
jsn = json.load(f)
jsn['assetDirectories'][1] = data[0] + "/mods/" # <--- add `mods` value.
jsn['storageDirectory'] = data[0] + "/storage/" # <--- add `storage` value.
f.seek(0) # <--- should reset file position to the beginning.
json.dump(jsn, f, indent=4)
f.truncate() # remove remaining part
#os.system('gnome-terminal -x ./starbound')
os.system('gnome-terminal -x steam steam://rungameid/starbound')
win = MyWindow()
win.connect('destroy', Gtk.main_quit)
win.show_all()
Gtk.main()