[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] Custom screensaver to override E's desklock (work in progress)....



Hello,

Hoping for comments on the attached patch.

The patch will add "Advanced" features to the Configuration Panel -> Screen -> Screen Lock panel. You can choose to override the "Lock Screen" functionality of E, and/or the E Screensaver with a "Custom Screensaver" which can be any executable you choose.

This is handy (I think). There have been some issues with PAM, while this is no fix for that... it does offer a suitable workaround. Especially for those of us who would choose to use things like xscreensaver in the first place.

Yes, you can say "well just disable E's" and configure xscreensaver. But it was annoying to me that I could not "reconfigure" the lock function to use <insert_fav_screensaver_here>. And this makes the E interface feel a little more consistent, in the sense that now I can use the menu "Lock Scree" option, or keybindings to activate the screensaver app of my choosing.

So, you can get a little creative with it. If you keep xscreensaver up and running , you might choose to use 'xscreensaver-command -lock' as your custom saver. This will lock the screen when you tell it to (using xscreensaver). Or (using the also attached script)... you could not run xscreensaver as a daemon, choose to use E's screensaver, override it using the new custom option, and allow E to manage the timer which starts xscreensaver.

The GUI changes I've made are a bit suspect as there are conditional compilations (ifdef HAVE_PAM) that may affect the location of GUI components. if some who does not HAVE_PAM could comment, that would be great too.

Anyway,  I was hoping someone could give it a try and comment.

--
Regards,
  Ravenlock
#!/bin/sh

# fire up xscreensaver
echo Launch xscreensaver
xscreensaver -no-splash &

# force it to lock
echo Lock it
xscreensaver-command -lock

# backgound the watch command
echo Start the watch command
xscreensaver-command -watch > ~/watch.out & 
xs_cmd_pid=$!
 
# watch the output for indication the screensaver has
# shutdown
echo begin waiting
while [ "`grep UNBLANK ~/watch.out`" = "" ]
do
  echo "  and waiting"
  sleep 1 
done
rm ~/watch.out
echo done waiting

# Kill off our "watcher"
kill -TERM $xs_cmd_pid

# kill of xscreensaver completely.  This allows E to 'manage'
# the screensaver/lock timers
xscreensaver-command -exit


Index: e17/apps/e/src/bin/e_config.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_config.c,v
retrieving revision 1.216
diff -u -r1.216 e_config.c
--- e17/apps/e/src/bin/e_config.c	15 Dec 2006 05:03:07 -0000	1.216
+++ e17/apps/e/src/bin/e_config.c	17 Dec 2006 08:16:59 -0000
@@ -478,6 +478,8 @@
    E_CONFIG_VAL(D, T, desklock_use_timeout, INT);
    E_CONFIG_VAL(D, T, desklock_timeout, DOUBLE);
    E_CONFIG_VAL(D, T, desklock_disable_screensaver, INT);
+   E_CONFIG_VAL(D, T, use_custom_screensaver, INT);
+   E_CONFIG_VAL(D, T, custom_screensaver_cmd, STR);
    E_CONFIG_VAL(D, T, display_res_restore, INT);
    E_CONFIG_VAL(D, T, display_res_width, INT);
    E_CONFIG_VAL(D, T, display_res_height, INT);
@@ -1275,6 +1277,12 @@
    e_config->theme_default_border_style = evas_stringshare_add("default");
    IFCFGEND;
    
+     
+   IFCFG(0x00106);
+   e_config->use_custom_screensaver = 0;
+   e_config->custom_screensaver_cmd = NULL;     
+   IFCFGEND;
+     
 #if 0 /* example of new config */
    IFCFG(0x0090); /* the version # where this value(s) was introduced */
    e_config->new_value = 10; /* set the value(s) */
@@ -1361,6 +1369,7 @@
    E_CONFIG_LIMIT(e_config->desklock_use_timeout, 0, 1);
    E_CONFIG_LIMIT(e_config->desklock_timeout, 1.0, 600.0);
    E_CONFIG_LIMIT(e_config->desklock_disable_screensaver, 0, 1);
+   E_CONFIG_LIMIT(e_config->use_custom_screensaver, 0, 1);
    E_CONFIG_LIMIT(e_config->display_res_restore, 0, 1);
    E_CONFIG_LIMIT(e_config->display_res_width, 1, 8192);
    E_CONFIG_LIMIT(e_config->display_res_height, 1, 8192);
Index: e17/apps/e/src/bin/e_config.h
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_config.h,v
retrieving revision 1.132
diff -u -r1.132 e_config.h
--- e17/apps/e/src/bin/e_config.h	15 Dec 2006 05:03:08 -0000	1.132
+++ e17/apps/e/src/bin/e_config.h	17 Dec 2006 08:17:00 -0000
@@ -51,7 +51,7 @@
 /* increment this whenever a new set of config values are added but the users
  * config doesn't need top be wiped - simply new values need to be put in
  */
-#define E_CONFIG_FILE_GENERATION 0x0104
+#define E_CONFIG_FILE_GENERATION 0x0106
 #define E_CONFIG_FILE_VERSION    ((E_CONFIG_FILE_EPOCH << 16) | E_CONFIG_FILE_GENERATION)
 
 #define E_EVAS_ENGINE_DEFAULT      0
@@ -230,7 +230,9 @@
    int         desklock_use_timeout; // GUI
    double      desklock_timeout; // GUI
    int         desklock_disable_screensaver; // GUI
-
+   int         use_custom_screensaver; //GUI
+   const char *custom_screensaver_cmd; // GUI
+   
    int         display_res_restore; // GUI
    int         display_res_width; // GUI
    int         display_res_height; // GUI
Index: e17/apps/e/src/bin/e_desklock.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_desklock.c,v
retrieving revision 1.28
diff -u -r1.28 e_desklock.c
--- e17/apps/e/src/bin/e_desklock.c	21 Oct 2006 02:32:13 -0000	1.28
+++ e17/apps/e/src/bin/e_desklock.c	17 Dec 2006 08:17:01 -0000
@@ -49,6 +49,8 @@
 static Ecore_Event_Handler *_e_desklock_exit_handler = NULL;
 static pid_t                _e_desklock_child_pid = -1;
 #endif
+static Ecore_Exe *_e_custom_saver_exe = NULL;
+static Ecore_Event_Handler *_e_custom_saver_exe_handler = NULL;
 
 /***********************************************************************/
 
@@ -57,6 +59,7 @@
 static int _e_desklock_cb_mouse_up(void *data, int type, void *event);
 static int _e_desklock_cb_mouse_wheel(void *data, int type, void *event);
 static int _e_desklock_cb_mouse_move(void *data, int type, void *event);
+static int _e_desklock_cb_custom_saver_exit(void *data, int type, void *event);
 
 static void _e_desklock_passwd_update();
 static void _e_desklock_backspace();
@@ -87,7 +90,7 @@
 
    if (e_config->desklock_background)
        e_filereg_register(e_config->desklock_background);
-
+   
    return 1;
 }
 
@@ -110,7 +113,18 @@
    E_Zone		  *current_zone;
    int			  zone_counter;
    int			  total_zone_num;
-
+   
+   if (_e_custom_saver_exe) return 0;
+   if (e_config->use_custom_screensaver)
+   {
+      _e_custom_saver_exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, 
+                                                _e_desklock_cb_custom_saver_exit, 
+                                                NULL);
+      _e_custom_saver_exe = ecore_exe_run(e_config->custom_screensaver_cmd, NULL);
+    
+      return 1;
+   }      
+   
    if (edd) return 0;
    
 #ifdef HAVE_PAM
@@ -323,8 +337,14 @@
 {
    E_Desklock_Popup_Data	*edp;
    
-   if (!edd) return;
+   if ((!edd) && (!_e_custom_saver_exe)) return;
 
+   if (e_config->use_custom_screensaver)
+   {
+      _e_custom_saver_exe = NULL;
+      return;
+   }
+   
    if (edd->elock_grab_break_wnd)
      ecore_x_window_show(edd->elock_grab_break_wnd);
    while (edd->elock_wnd_list)
@@ -735,3 +755,22 @@
    return strdup("localhost");
 }
 #endif
+
+static int
+_e_desklock_cb_custom_saver_exit(void *data, int type, void *event)
+{
+   Ecore_Exe_Event_Del *ev;
+  
+   ev = event;
+   if (ev->exe != _e_custom_saver_exe) return 1;
+   
+   if (ev->exit_code != 0)
+   {
+	      /* do something profound here... like notify someone */
+   }
+   else
+      e_desklock_hide();
+   
+
+   return 0;
+}
Index: e17/apps/e/src/bin/e_int_config_desklock.c
===================================================================
RCS file: /var/cvs/e/e17/apps/e/src/bin/e_int_config_desklock.c,v
retrieving revision 1.43
diff -u -r1.43 e_int_config_desklock.c
--- e17/apps/e/src/bin/e_int_config_desklock.c	14 Dec 2006 19:42:21 -0000	1.43
+++ e17/apps/e/src/bin/e_int_config_desklock.c	17 Dec 2006 08:17:01 -0000
@@ -65,6 +65,9 @@
    int specific_lb_zone; // local variable
    int specific_lb_zone_backup; // used to have smart iface
    
+   int use_custom_screensaver;
+   char *custom_screensaver_cmd;
+   
    int zone_count; // local variable;
 
    int bg_mode; // config
@@ -351,6 +354,10 @@
    cfdata->auth_method = e_config->desklock_auth_method;
 #endif
    
+   cfdata->use_custom_screensaver = e_config->use_custom_screensaver;
+   if (e_config->custom_screensaver_cmd)
+      cfdata->custom_screensaver_cmd = strdup(e_config->custom_screensaver_cmd);
+     
    //vertical_lb_align = e_config->desklock_login
 }
 
@@ -523,6 +530,14 @@
    if (e_config->desklock_use_timeout)
      ecore_x_screensaver_timeout_set(e_config->desklock_timeout);
    
+   e_config->use_custom_screensaver = cfdata->use_custom_screensaver;
+   e_config->custom_screensaver_cmd = cfdata->custom_screensaver_cmd;
+   if (e_config->custom_screensaver_cmd)
+	   evas_stringshare_del(e_config->custom_screensaver_cmd);
+   if (cfdata->custom_screensaver_cmd)
+      e_config->custom_screensaver_cmd = evas_stringshare_add(cfdata->custom_screensaver_cmd);
+
+   
    e_config_save_queue();
    return 1;
 }
@@ -764,7 +779,7 @@
    
    e_widget_disabled_set(of, !ecore_x_screensaver_event_available_get());
    
-   ob = e_widget_check_add(evas, _("Enable screensaver"), &(cfdata->use_timeout));
+   ob = e_widget_check_add(evas, _("Enable Enlightenment's screensaver"), &(cfdata->use_timeout));
    e_widget_disabled_set(ob, !ecore_x_screensaver_event_available_get());
    e_widget_framelist_object_append(of, ob);
    
@@ -785,6 +800,23 @@
 #else
    e_widget_table_object_append(ot, of, 1, 2, 1, 1 ,1 ,1 ,1 ,1);
 #endif
+
+   /* 
+    * Allow Custom Screen Saver
+    *   Useful, for example, for those of us who prefer
+    *   to use things like xscreensaver, kscreesaver, etc...
+    */
+   of = e_widget_framelist_add(evas, _("Custom Screensaver"), 0);
+   ob = e_widget_check_add(evas, _("Use custom screensaver (Overrides E's desklock)"), 
+                           &(cfdata->use_custom_screensaver));
+   e_widget_framelist_object_append(of, ob);
+   ob = e_widget_entry_add(evas, &(cfdata->custom_screensaver_cmd));
+   e_widget_framelist_object_append(of, ob);
+#ifdef HAVE_PAM
+   e_widget_table_object_append(ot, of, 0, 4, 2, 1, 1, 1, 1, 1);
+#else
+   e_widget_table_object_append(ot, of, 0, 4, 2, 1, 1, 1, 1, 1);
+#endif
    
    e_dialog_resizable_set(cfd->dia, 0);
    return ot;