The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

i3lock: How to enable auto-lock AFTER wake up from suspend? [SOLVED]

asked 2014-12-05 14:05:24 +0000

anonymous user

Anonymous

updated 2014-12-31 02:12:01 +0000

Hello i3-community,

trying i3 since several days: fantastic window manager!

Using i3 My config is complete so far related to lock-functions.

Autostart for i3lock is the following:

exec --no-startup-id xautolock -time 5 -locker i3lock &

Lock by pressing a key is the following:

bindsym $mod+Pause exec --no-startup-id i3lock -c 000000

Now I have two questions:

  1. How can I set the color of the autostart-locker to 000000 as well?
  2. After waking up from suspend the system is NOT locked. How can I set this up?

Using i3wm under debian wheezy (but installed via backports) in the following versions:

i3 version 4.8 (2014-06-15, branch "4.8")

i3lock version 2.4.1 (2012-06-02)

Thank you in advance! sj7

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-12-06 18:40:50 +0000

cee gravatar image

Educated guess on question 1)
This should be possible with the proper use of apostrophes. Untested, but something like:

exec --no-startup-id xautolock -time 5 -locker 'i3lock -c 000000' &

For question 2)
I am using i3exit.sh found on this site and adjusted to my likings. My suspend command:

i3lock -c 000000 && systemctl suspend

You could also easily bind a key to a chained command like this:

i3-msg exec 'i3lock -c 000000' && systemctl suspend

You can take a look at my config on github.

edit flag offensive delete link more
0

answered 2014-12-07 16:15:04 +0000

saljut7 gravatar image

updated 2014-12-07 16:19:01 +0000

Hello cee and thanks for your helping answer!

1) Unfortunately

exec --no-startup-id xautolock -time 5 -locker 'i3lock -c 000000' &

still causes a white lock-screen.

2) I deployed the i3exit.sh in ~/.i3 and modified my i3-config. Pressing the specified button calls the menu correctly. Lock works, but it seems that everything that calls systemctl doesn't work.

#!/bin/bash
############################################################
#
############################################################
function lock {
    i3lock -c 000000
}
case "$1" in
    lock)
        lock
        ;;
    logout)
        i3-msg exit
        ;;
    suspend)
        lock && systemctl suspend
        ;;
    reboot)
        systemctl reboot
        ;;
    poweroff)
        systemctl poweroff
        ;;
    *)
        echo "Usage: $0 {lock|logout|suspend|reboot|poweroff}"
        exit 2
esac

exit 0

Well, my distri uses a python-script for the logout/susp/exit-functions:

#!/usr/bin/env python

import pygtk
pygtk.require('2.0')
import gtk
import os
import getpass

class cb_exit:
    def disable_buttons(self):
        self.cancel.set_sensitive(False)
        self.logout.set_sensitive(False)
        self.suspend.set_sensitive(False)
        self.reboot.set_sensitive(False)
        self.shutdown.set_sensitive(False)

    def cancel_action(self,btn):
        self.disable_buttons()
        gtk.main_quit()

    def logout_action(self,btn):
        self.disable_buttons()
        self.status.set_label("Exiting Openbox, please standby...")
        os.system("openbox --exit")

    def suspend_action(self,btn):
        self.disable_buttons()
        self.status.set_label("Suspending, please standby...")
        os.system("cb-lock")
        os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.freedesktop.UPower.Suspend")
        gtk.main_quit()

    def reboot_action(self,btn):
        self.disable_buttons()
        self.status.set_label("Rebooting, please standby...")
        os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart")

    def shutdown_action(self,btn):
        self.disable_buttons()
        self.status.set_label("Shutting down, please standby...")
        os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop")

    def create_window(self):
        self.window = gtk.Window()
        title = "Log out " + getpass.getuser() + "? Choose an option:"
        self.window.set_title(title)
        self.window.set_border_width(5)
        self.window.set_size_request(500, 80)
        self.window.set_resizable(False)
        self.window.set_keep_above(True)
        self.window.stick
        self.window.set_position(1)
        self.window.connect("delete_event", gtk.main_quit)
        windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
        self.window.set_icon(windowicon)


        #Create HBox for buttons
        self.button_box = gtk.HBox()
        self.button_box.show()

        #Cancel button
        self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL)
        self.cancel.set_border_width(4)
        self.cancel.connect("clicked", self.cancel_action)
        self.button_box.pack_start(self.cancel)
        self.cancel.show()

        #Logout button
        self.logout = gtk.Button("_Log out")
        self.logout.set_border_width(4)
        self.logout.connect("clicked", self.logout_action)
        self.button_box.pack_start(self.logout)
        self.logout.show()

        #Suspend button
        self.suspend = gtk.Button("_Suspend")
        self.suspend.set_border_width(4)
        self.suspend.connect("clicked", self.suspend_action)
        self.button_box.pack_start(self.suspend)
        self.suspend.show()

        #Reboot button
        self.reboot = gtk.Button("_Reboot")
        self.reboot.set_border_width(4)
        self.reboot.connect("clicked", self.reboot_action)
        self.button_box.pack_start(self.reboot)
        self.reboot.show()

        #Shutdown button
        self.shutdown = gtk.Button("_Power off")
        self.shutdown.set_border_width(4)
        self.shutdown.connect("clicked", self.shutdown_action)
        self.button_box.pack_start(self.shutdown)
        self.shutdown.show()

        #Create HBox for status label
        self.label_box = gtk.HBox()
        self.label_box.show()
        self.status = gtk.Label()
        self.status.show()
        self.label_box.pack_start(self.status)

        #Create VBox and pack the above HBox's
        self ...
(more)
edit flag offensive delete link more

Comments

You have sudo problems. Whenever a command requires sudo, make sure you include the `sudo` part of the command in your binding and give youself NOPASSWD in /etc/sudoers for the current command. Example: `tasinet ALL=NOPASSWD: /usr/sbin/pm-suspend` and `$mod+blah exec sudo pm-suspend`

tasinet gravatar imagetasinet ( 2014-12-07 17:55:24 +0000 )edit

Hostname was missing but works now, thank you very much! For everyone who has the same problems: In terminal sudo visudo and add <your user=""> <your hostname=""> = (root) NOPASSWD: /usr/sbin/pm-suspend Add to your i3-config: bindsym <your key-combi=""> exec --no-startup-id sudo pm-suspend && i3lock Rdy!

saljut7 gravatar imagesaljut7 ( 2014-12-31 02:11:04 +0000 )edit

Question Tools

2 followers

Stats

Asked: 2014-12-05 14:05:24 +0000

Seen: 2,531 times

Last updated: Dec 31 '14