Skip to content

Commit

Permalink
mate-screensaver-command: Support unlocking (--unlock) the screensave…
Browse files Browse the repository at this point in the history
…r via CLI.
  • Loading branch information
sunweaver authored and raveit65 committed Jan 25, 2019
1 parent 84a14f0 commit 11fedfe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/mate-screensaver-command.1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Query the length of time the screensaver has been active
.B \-l, \-\-lock
Tells the running screensaver process to lock the screen immediately
.TP
.B \-u, \-\-unlock
Tells the running screensaver process to unlock the screen immediately
.TP
.B \-c, \-\-cycle
If the screensaver is active then switch to another graphics demo
.TP
Expand Down
9 changes: 9 additions & 0 deletions doc/dbus-interface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
</para>
</sect2>

<sect2 id="gs-method-Unlock">
<title>
<literal>Unlock</literal>
</title>
<para>
Request that the screen be unlocked.
</para>
</sect2>

<sect2 id="gs-method-Cycle">
<title>
<literal>Cycle</literal>
Expand Down
7 changes: 7 additions & 0 deletions src/gs-listener-dbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,8 @@ do_introspect (DBusConnection *connection,
" <interface name=\"org.mate.ScreenSaver\">\n"
" <method name=\"Lock\">\n"
" </method>\n"
" <method name=\"Unlock\">\n"
" </method>\n"
" <method name=\"Cycle\">\n"
" </method>\n"
" <method name=\"SimulateUserActivity\">\n"
Expand Down Expand Up @@ -1465,6 +1467,11 @@ listener_dbus_handle_session_message (DBusConnection *connection,
g_signal_emit (listener, signals [LOCK], 0);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Unlock"))
{
gs_listener_set_active (listener, FALSE);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus_message_is_method_call (message, GS_LISTENER_SERVICE, "Quit"))
{
g_signal_emit (listener, signals [QUIT], 0);
Expand Down
10 changes: 10 additions & 0 deletions src/mate-screensaver-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

static gboolean do_quit = FALSE;
static gboolean do_lock = FALSE;
static gboolean do_unlock = FALSE;
static gboolean do_cycle = FALSE;
static gboolean do_activate = FALSE;
static gboolean do_deactivate = FALSE;
Expand Down Expand Up @@ -70,6 +71,10 @@ static GOptionEntry entries [] =
"lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
N_("Tells the running screensaver process to lock the screen immediately"), NULL
},
{
"unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
N_("Tells the running screensaver process to unlock the screen immediately"), NULL
},
{
"cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
N_("If the screensaver is active then switch to another graphics demo"), NULL
Expand Down Expand Up @@ -423,6 +428,11 @@ do_command (DBusConnection *connection)
reply = screensaver_send_message_void (connection, "Lock", FALSE);
}

if (do_unlock)
{
reply = screensaver_send_message_void (connection, "Unlock", FALSE);
}

if (do_cycle)
{
reply = screensaver_send_message_void (connection, "Cycle", FALSE);
Expand Down

0 comments on commit 11fedfe

Please sign in to comment.