summaryrefslogtreecommitdiff
path: root/tools/dev_env_setup/templates/add_dev_tools_folder.py
blob: d90d797a4908bf9c3ce2e39a2172026d4326e399 (plain)
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
#!/usr/bin/python
import json
import os
import time
from gi.repository import Gio, Gtk, GLib

DIRECTORY_ID = 'eos-folder-user-99.directory'
DIRECTORY_FILE_CONTENT="""[Desktop Entry]
Name=Development
Icon=eos-folder-tools-symbolic
Type=Directory
"""

DEFAULT_LAYOUT_FILE='/usr/share/EndlessOS/personality-defaults/icon-grid-default.json'
DESTINATIION_FOLDER= os.path.expanduser('~/.local/share/desktop-directories/') + DIRECTORY_ID

def get_default_layout():
    with open(DEFAULT_LAYOUT_FILE, 'r') as f:
        return f.read()


def write_folder_data():
    with open(DESTINATIION_FOLDER, 'w') as f:
        return f.write(DIRECTORY_FILE_CONTENT)

def get_settings_string(layout):
    settings = Gio.Settings.new("org.gnome.shell")


    loaded_layout = json.loads(layout)
    loaded_layout['desktop'].append(DIRECTORY_ID)
    loaded_layout[DIRECTORY_ID] = [ 'eos-app-gnome-terminal.desktop' ,
                                    'eos-app-devhelp.desktop' ]

    root=GLib.Variant('a{sas}', loaded_layout)
    print "Setting the value"
    settings.set_value("icon-grid-layout", root)
    print "Syncing"
    settings.apply()
    settings.sync()
    print root

    time.sleep(20)

if __name__ == "__main__":
    layout = get_default_layout()
    write_folder_data()
    get_settings_string(layout)