-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgset
executable file
·49 lines (39 loc) · 1.16 KB
/
gset
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
#!/usr/bin/env ruby
# coding: utf-8
# desc: gsettings automation based on yaml data
# author: eric
require 'yaml'
data = File.expand_path "~/.gset.yaml"
settings = YAML.load_file data
general = settings['general']
keybindings = settings['keybindings']
def exc cmd
if system cmd
print "[" + "\e[32m" + "done" + "\e[0m" + "]" # done: green
else
print "[" + "\e[31m" + "failed" + "\e[0m" + "]" # failed: red
end
print cmd + "\n\n"
end
# general settings
general.each do |cfg|
cfg['setting'].each do |key, value|
exc "gsettings set #{cfg['schema']} #{key} \"#{value}\""
end
end
# custom keybindings
exit if keybindings == nil
keybindings_path = []
keybindings.size.times do |i|
path = "/org/gnome/settings-daemon/plugins/media-keys/" +
"custom-keybindings/custom#{i}/"
keybindings_path << path
keybindings[i].each do |key, value|
exc "gsettings set " +
"org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:" +
"#{path} #{key} \"#{value}\""
end
end
exc "gsettings set " +
"org.gnome.settings-daemon.plugins.media-keys custom-keybindings " +
'"[' + keybindings_path.map{|p|"'#{p}'"}.join(", ") + ']"'