Created attachment 9341 Patch to add lock button to 1.1.0 The time left dialog would be much more useful with a lock button. During the break if I want to leave the computer, sometimes it would be useful to be able to lock the screen so a password is required to get back on the computer. The attached patch implements this feature by adding a lock button that will run xflock4 when it is pressed. Possible things to fix with patch before merging: 1. Put Lock button horizontally with Postpone button instead of vertically. 2. Resume locking screen instead of exiting if xflock4 fails. Let me know if there is anything you would like me to do to improve this patch. Thanks. Joshua Cogliati
Hm, this needs more testing. Sometimes the lock button doesn't work (or needs to be pressed multiple times)
Switching to g_spawn_command_line_sync sorta solves the problem. However, with xscreensaver, it doesn't always start until the mouse is moved (as in, click Lock, then wait a moment, then move the mouse) Here is the second attempt at the code (with debugging statements left in: static void time_out_lock (TimeOutLockScreen *lock_screen, TimeOutPlugin *time_out) { GError *error = NULL; gboolean succeed = FALSE; gint exit_status; { FILE *fp; fp = fopen ("/tmp/panel_out", "a+"); fputs("in time_out_lock\n", fp); fclose(fp); } g_return_if_fail (IS_TIME_OUT_LOCK_SCREEN (lock_screen)); g_return_if_fail (time_out != NULL); /* Unlock the screen so screensaver can show */ time_out_lock_screen_hide (time_out->lock_screen); /* Lock screen and check for errors */ //succeed = g_spawn_command_line_async ("xflock4", &error); //g_usleep (10*1000); succeed = g_spawn_command_line_sync ("xflock4", NULL, NULL, &exit_status , &error); { FILE *fp; fp = fopen ("/tmp/panel_out", "a+"); fprintf(fp, "exit status %d\n", exit_status); if (succeed) { fputs("locked screen\n", fp); } else { fputs("failed to lock screen\n", fp); } fclose(fp); } if (!succeed) { xfce_dialog_show_error (NULL, error, _("Failed to lock screen")); } else { /* Display the lock screen under screensaver */ time_out_lock_screen_show (time_out->lock_screen, time_out->lock_countdown_seconds); } }
Created attachment 9349 Patch to add lock button to 1.1.0 with sync This switches to using sync instead of async to fix a bug. This also puts the button horizontally with the postpone button.
I like this idea, very handy indeed, however the latest patch doesn't for well for me, I use i3lock-fancy. After locking and unlocking, the countdown dialog is gone but the blocking overlay remains.
(In reply to Andre Miranda from comment #4) > I like this idea, very handy indeed, however the latest patch doesn't for > well for me, I use i3lock-fancy. After locking and unlocking, the countdown > dialog is gone but the blocking overlay remains. Just out of curiosity, what happens if you use "Lock Screen" in the action buttons? Does that work for you? (or running "xflock4" from the command line?)
Both work, calling the lock screen (i3lock) from the break screen also works, the problem is because your patch hides the break screen, calls the lock screen and then shows the break screen again, cool, my screen is locked, but when I unlock time-out-plugin is still blocking it with its overlay but no dialog in the center allowing me to lock again or postpone.
Just for the record, someone told me this problem is already present if the screen is locked while time-out-plugin is blocking it (can't check right now). So it may be another bug, possibly related to the gtk3 port.
Hm, maybe the code should always show the time out screen again instead of being in the else branch: if (!succeed) { xfce_dialog_show_error (NULL, error, _("Failed to lock screen")); } /* Display the lock screen under screensaver */ time_out_lock_screen_show (time_out->lock_screen, time_out->lock_countdown_seconds);
Created attachment 9372 updated patch to add lock button This patch moves restarting the dialog out of the else block. This fixes the minor problem that if xflock4 errors out the timing never gets restarted.
Even with your latest patch I have the same issue. Add the functions below and calling them instead time_out_lock_screen_hide/show did the trick for me. Is there any reason to hide the blocking dialog before locking other than allowing the screen locker to grab? void time_out_lock_screen_grab (TimeOutLockScreen *lock_screen) { time_out_lock_screen_grab_seat (lock_screen->seat, lock_screen->window); } void time_out_lock_screen_ungrab (TimeOutLockScreen *lock_screen) { gdk_seat_ungrab (lock_screen->seat); } Notice that grab won't work because the screen locker holds it, you can add parameters to time_out_lock_screen_grab_seat so it knows it should try to grab indefinitely and with a larger retry interval (i.e. 1 sec).
Created attachment 9381 Patch using grab ungrab This turns Andre Miranda comment into a patch. Thank you for the suggestion. > Is there any reason to hide the blocking dialog before locking other than allowing the screen locker to grab? No, that was the reason I hid it.
Created attachment 9392 Patch using grab and ungrab This patch uses grab seat and ungrab seat as suggested by Andre Miranda. This patch is functionally the same as the previous version but with better comments and moving the prototypes to the header file.
Created attachment 9404 Patch using grab and ungrab This patch uses grab and ungrab. I have tested this method for a week with both xscreensaver and xfce4-screensaver, and it works fine for me. (I thought it had a problem with sometimes keeping the keyboard, but that was because I had both xsceensaver and xfce4-screensaver running at the same time.)
Joshua Cogliati referenced this bugreport in commit f62ea6c46175c32d69ffba51d5f71cfcd3f8f397 Add lock button to break dialog (Bug #16317) https://git.xfce.org/panel-plugins/xfce4-time-out-plugin/commit?id=f62ea6c46175c32d69ffba51d5f71cfcd3f8f397
Hi Joshua, thanks for the last patch, it works nicely for me, great job! I have made a few changes to it though: - Formatting (only spaces instead of tabs) - Make postpone and lock buttons fill the horizontal space - Hide lock button when break time is over - Made you the commit author (hope you don't mind) I did a release of this plugin not long ago (3 months) so I going to wait a bit more, if you have more improvements underway please let me know. If not and I forgot to release it, please ping me at #xfce-dev.
Thank you for applying the patch. I don't have any more improvements underway. (In reply to Andre Miranda from comment #15)