/usr/bin/cinnamon-killer-daemon is in cinnamon 3.6.7-8ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/python3
""" Creates a keybinding that allows cinnamon to be restarted by pressing Ctrl + Alt + Esc,
and runs in the background to detect that keybinding
"""
import os
import syslog
import gi
gi.require_version('Keybinder', '3.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Keybinder
from gi.repository import Gtk, Gio
SETTINGS_SCHEMA = 'org.cinnamon.desktop.keybindings.media-keys'
SETTINGS_KEY = 'restart-cinnamon'
class KillerDaemon:
def __init__(self):
Keybinder.init()
self.bindings = None
self.settings = Gio.Settings(schema_id=SETTINGS_SCHEMA)
self.apply_bindings()
self.settings.connect('changed::' + SETTINGS_KEY, self.apply_bindings)
def apply_bindings(self, settings=None, key=None):
# Ubind the previous bindings
try:
if self.bindings is not None:
for binding in self.bindings:
Keybinder.unbind(binding)
except Exception as detail:
syslog.syslog(detail)
# Get the new ones
self.bindings = self.settings.get_strv(SETTINGS_KEY)
# Bind them
try:
if self.bindings is not None:
for binding in self.bindings:
if Keybinder.bind(binding, self.restart_cinnamon, None):
syslog.syslog("Bound Cinnamon restart to %s." % binding)
except Exception as detail:
syslog.syslog(detail)
def restart_cinnamon(self, keystring, data):
os.system("nemo -n &") # restart nemo if it's not running already
os.system("cinnamon --replace &") # restart Cinnamon whether it's running or not (can be handy in case of a DE freeze)
if __name__ == '__main__':
daemon = KillerDaemon()
Gtk.main()
|