2024-05-15 15:29:05 +00:00
|
|
|
#!/usr/bin/env lua
|
2024-05-15 19:44:56 +00:00
|
|
|
-- Entries contain three strings: 1 - name, 2 - shell command, and 3 - keybinding.
|
|
|
|
local entries = {
|
2024-05-15 15:29:05 +00:00
|
|
|
{
|
2024-05-15 19:44:56 +00:00
|
|
|
"Toggle terminal transparency",
|
|
|
|
"${HOME}/scripts/toggle-term-transparency.sh",
|
|
|
|
"<Primary>dead_acute",
|
2024-05-15 15:29:05 +00:00
|
|
|
},
|
2024-05-15 19:44:56 +00:00
|
|
|
{ "Toggle bg", "${HOME}/scripts/switch-bg.sh t", "<Primary>ccedilla" },
|
2024-05-15 15:29:05 +00:00
|
|
|
}
|
2024-05-15 19:44:56 +00:00
|
|
|
local addQuotes = function(str)
|
|
|
|
return '"' .. str .. '"'
|
|
|
|
end
|
|
|
|
local makeBinding = function(str)
|
|
|
|
return "\"['" .. str .. "']\""
|
|
|
|
end
|
|
|
|
-- create and set custom_list. Gsettings needs this in order to create bindings before they can be modified.
|
2024-05-15 15:29:05 +00:00
|
|
|
local custom_list = '"['
|
2024-05-15 19:44:56 +00:00
|
|
|
for i, _ in pairs(entries) do
|
2024-05-15 15:29:05 +00:00
|
|
|
custom_list = custom_list .. "'custom" .. (i - 1) .. "',"
|
|
|
|
end
|
2024-05-15 19:44:56 +00:00
|
|
|
-- remove last comma, close bracket etc
|
2024-05-15 15:29:05 +00:00
|
|
|
custom_list = custom_list:sub(1, custom_list:len() - 1) .. ']"'
|
|
|
|
os.execute("gsettings set org.cinnamon.desktop.keybindings custom-list " .. custom_list)
|
2024-05-15 19:44:56 +00:00
|
|
|
-- set bindings
|
2024-05-15 15:29:05 +00:00
|
|
|
local gset = function(index, name, command, binding)
|
|
|
|
local cmd = "gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom"
|
|
|
|
.. index
|
|
|
|
.. "/ name "
|
2024-05-15 19:44:56 +00:00
|
|
|
.. addQuotes(name)
|
2024-05-15 15:29:05 +00:00
|
|
|
os.execute(cmd)
|
|
|
|
cmd = "gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom"
|
|
|
|
.. index
|
|
|
|
.. "/ command "
|
2024-05-15 19:44:56 +00:00
|
|
|
.. addQuotes(command)
|
2024-05-15 15:29:05 +00:00
|
|
|
os.execute(cmd)
|
|
|
|
cmd = "gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom"
|
|
|
|
.. index
|
|
|
|
.. "/ binding "
|
2024-05-15 19:44:56 +00:00
|
|
|
.. makeBinding(binding)
|
2024-05-15 15:29:05 +00:00
|
|
|
os.execute(cmd)
|
|
|
|
end
|
2024-05-15 19:44:56 +00:00
|
|
|
for i, entry in pairs(entries) do
|
|
|
|
gset(i - 1, entry[1], entry[2], entry[3])
|
2024-05-15 15:29:05 +00:00
|
|
|
end
|
2024-05-15 19:44:56 +00:00
|
|
|
print("REMEMBER: Cinnamon has to be restarted (ctrl+alt+esc) before these changes will take effect!")
|