@@ -0,0 +1,1510 @@
+import subprocess%0Aimport shlex%0A%0Aimport bumblebee.module%0A%0Adef description():%0A    return %22Enable/disable auto screen lock.%22%0A%0Aclass Module(bumblebee.module.Module):%0A    def __init__(self, output, config, alias):%0A        super(Module, self).__init__(output, config, alias)%0A        self._activated = 0%0A        # output.add_callback(module=%22caffeine.activate%22, button=1, cmd='notify-send %22Consuming caffeine%22; xset s off')%0A        # output.add_callback(module=%22caffeine.deactivate%22, button=1, cmd='notify-send %22Out of coffee%22; xset s 600 600')%0A        output.add_callback(module=%22caffeine.activate%22, button=1, cmd='xset s off')%0A        output.add_callback(module=%22caffeine.deactivate%22, button=1, cmd='xset s 600 600')%0A%0A    def widgets(self):%0A        output = subprocess.check_output(shlex.split(%22xset q%22))%0A        xset_out = output.decode().split(%22%5Cn%22)%0A        for line in xset_out:%0A            if line.startswith(%22  timeout%22):%0A                timeout = int(line.split(%22 %22)%5B4%5D)%0A                if timeout == 0:%0A                    self._activated = 1;%0A                else:%0A                    self._activated = 0;%0A                break%0A%0A        if self._activated == 0:%0A            return bumblebee.output.Widget(self, %22%22, instance=%22caffeine.activate%22)%0A        elif self._activated == 1:%0A            return bumblebee.output.Widget(self, %22%22, instance=%22caffeine.deactivate%22)%0A%0A    def state(self, widget):%0A        if self._activated == 1:%0A            return %22activated%22%0A        else:%0A            return %22deactivated%22%0A%0A

Add caffeine module to prevent sleep