/usr/bin/cinnamon-killer-daemon is in cinnamon 2.8.6-1ubuntu1.
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 | #!/usr/bin/python2
# -*- coding: utf-8 -*-
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
import os
import syslog
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, 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, 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-settings-daemon &") # restart CSD 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()
|