4

So, I've been trying to create a USB key for my machine.

I've used PAM-Usb as described in many places over the internet (for example this one, which is basically copypasted everywhere). I understand what happens there and thats pretty neat.

My problem is - if I lock screen (with button, plugging USB off or with gnome-screensaver-command -l), then gnome-screensaver-command -d won't bring me back to my desktop, but rather wakes up the monitor. I still have to provide password - and I don't want that when I plug USB stick in.

I don't want to turn off password prompt at unlock. I want my computer freely accessible at any given moment when USB stick is plugged in and accessible with password in other case.

So, the question is: how do I unlock gnome-screensaver with a command line?

PS. Funny thing: if I use a USB key, then I don't have to provide password when logging in. On the other hand, on unlock it is needed. I understand why it happens, but still, it looks weird.

==EDIT==

I forgot: I'm using plain (meaning Unity-based) Ubuntu 15.04. No screensaver-related modifications were made.

1
  • Yeah, so... Bounty has expired and neither of provided solutions worked... :/ Well, it was worth a try. Oct 12, 2015 at 20:11

2 Answers 2

4

Ubuntu 14.04+ no longer uses gnome-screensaver, that's why gnome-screensaver-command -d may not work (probably, I'm not sure, but Ubuntu has replaced the old gnome-screensaver with something new and that command doesn't work currently). You can lock and unlock your computer using dbus.

Lock:

dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

Unlock:

dbus-send --session --dest=org.gnome.ScreenSaver --type=method_call --print-reply --reply-timeout=20000 /org/gnome/ScreenSaver org.gnome.ScreenSaver.SetActive boolean:false

It should unlock without asking for password.

1
  • iirc, that's what gnome-screensaver-command does as well
    – user448115
    Sep 24, 2015 at 8:03
0

In 15.04 the lock screen is implemented in unity.

It appears that libpam_usb is not explicitly linked with libpam, as it (falsely) expects that the program using it has libpam already loaded. This is the case for most programs (i.e. sudo, lightdm etc) but not for compiz. A change in the makefile of libpam-usb and recompilation is required to fix it.

Though as a workaround you can edit /usr/share/applications/compiz.desktop and replace

Exec=compiz

with

Exec=/bin/sh -c "LD_PRELOAD=libpam.so compiz"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .