From defc5dca82a0fb1d96a08ef8734dd646776145e2 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Fri, 15 May 2009 12:23:46 +0000 Subject: [PATCH] Autostart code is now placed in external, ede-autostart file. This should make it easier for extending and calling from external programs, without cluttering evoke --- evoke/Jamfile | 4 +- evoke/ede-autostart.cpp | 105 ++++++++++++++------- evoke/ede-startup.conf | 9 +- evoke/evoke.cpp | 12 --- evoke/splash-themes/scape/autostart.png | Bin 0 -> 1959 bytes evoke/splash-themes/standard/autostart.png | Bin 0 -> 1959 bytes 6 files changed, 82 insertions(+), 48 deletions(-) create mode 100644 evoke/splash-themes/scape/autostart.png create mode 100644 evoke/splash-themes/standard/autostart.png diff --git a/evoke/Jamfile b/evoke/Jamfile index 551e17f..909f97a 100644 --- a/evoke/Jamfile +++ b/evoke/Jamfile @@ -15,7 +15,6 @@ SOURCE = evoke.cpp Splash.cpp Xsm.cpp Logout.cpp - Autostart.cpp Xshutdown.cpp ; CONFIG = ede-settings.conf @@ -35,6 +34,9 @@ ObjectC++Flags ede-shutdown : $(X_CFLAGS) ; ProgramBare ede-shutdown : ede-shutdown.cpp ; LinkAgainst ede-shutdown : $(X_LIBS) -lX11 ; +EdeProgram ede-autostart : ede-autostart.cpp ; +ObjectC++Flags ede-autostart : -DDEBUG_AUTOSTART_RUN ; + InstallEdeProgram ede-settings-apply ; EdeManualWithToc [ FFileName doc evoke.txt ] ; diff --git a/evoke/ede-autostart.cpp b/evoke/ede-autostart.cpp index 7a57052..a0f30f5 100644 --- a/evoke/ede-autostart.cpp +++ b/evoke/ede-autostart.cpp @@ -1,7 +1,7 @@ /* * $Id$ * - * Evoke, head honcho of everything + * ede-autostart * Part of Equinox Desktop Environment (EDE). * Copyright (c) 2007-2009 EDE Authors. * @@ -10,8 +10,14 @@ * See COPYING for details. */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include +#include + #include #include #include @@ -29,7 +35,6 @@ #include #include -#include "Autostart.h" #include "icons/warning.xpm" EDELIB_NS_USING(String) @@ -41,12 +46,16 @@ EDELIB_NS_USING(user_config_dir) EDELIB_NS_USING(str_ends) EDELIB_NS_USING(run_async) +#define CHECK_ARGV(argv, pshort, plong) ((strcmp(argv, pshort) == 0) || (strcmp(argv, plong) == 0)) + #ifdef DEBUG_AUTOSTART_RUN #define AUTOSTART_RUN(s) E_DEBUG("Executing %s\n", s) #else #define AUTOSTART_RUN(s) run_async(s) #endif +#define AUTOSTART_DIRNAME "/autostart/" + struct DialogEntry { String name; String exec; @@ -178,32 +187,9 @@ static void run_autostart_dialog(DialogEntryList& l) { Fl::wait(); } -/* - * This is implementation of Autostart Spec - * (http://standards.freedesktop.org/autostart-spec/autostart-spec-0.5.html). - * - * The Autostart Directories are $XDG_CONFIG_DIRS/autostart. - * If the same filename is located under multiple Autostart Directories only the file under - * the most important directory should be used. - * - * Example: If $XDG_CONFIG_HOME is not set the Autostart Directory in the user's home directory - * is ~/.config/autostart/ - * Example: If $XDG_CONFIG_DIRS is not set the system wide Autostart Directory is /etc/xdg/autostart/ - * Example: If $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS are not set and the two files - * /etc/xdg/autostart/foo.desktop and ~/.config/autostart/foo.desktop exist then only the file - * ~/.config/autostart/foo.desktop will be used because ~/.config/autostart/ is more important - * than /etc/xdg/autostart/. - * - * If Hidden key is set true in .desktop file, file MUST be ignored. - * OnlyShowIn and NotShowIn (list of strings identifying desktop environments) if (or if not) - * contains environment name, MUST not be started/not started. - * TryExec is same as for .desktop spec. - */ -void perform_autostart(bool safe) { - const char* autostart_dirname = "/autostart/"; - +static void perform_autostart(bool safe) { String adir = edelib::user_config_dir(); - adir += autostart_dirname; + adir += AUTOSTART_DIRNAME; StringList dfiles, sysdirs, tmp; StringListIter it, it_end, tmp_it, tmp_it_end; @@ -213,7 +199,7 @@ void perform_autostart(bool safe) { system_config_dirs(sysdirs); if(!sysdirs.empty()) { for(it = sysdirs.begin(), it_end = sysdirs.end(); it != it_end; ++it) { - *it += autostart_dirname; + *it += AUTOSTART_DIRNAME; /* * append content @@ -243,7 +229,7 @@ void perform_autostart(bool safe) { unique_by_basename(dfiles); const char* name; - char buff[1024]; + char buf[1024]; DesktopFile df; DialogEntryList entry_list; @@ -265,15 +251,15 @@ void perform_autostart(bool safe) { if(df.hidden()) continue; - if(!(df.try_exec(buff, sizeof(buff)) || df.exec(buff, sizeof(buff)))) + if(!(df.try_exec(buf, sizeof(buf)) || df.exec(buf, sizeof(buf)))) continue; DialogEntry* en = new DialogEntry; - en->exec = buff; + en->exec = buf; /* figure out the name */ - if(df.name(buff, sizeof(buff))) - en->name = buff; + if(df.name(buf, sizeof(buf))) + en->name = buf; else en->name = name; @@ -285,3 +271,56 @@ void perform_autostart(bool safe) { else entry_list_run_clear(entry_list, true); } + +static void help(void) { + puts("Usage: ede-autostart [OPTIONS]"); + puts("EDE autostart utility"); + puts("Options:"); + puts(" -h, --help this help"); + puts(" -s, --safe show dialog of commands to be executed"); + puts(" -m, --media [DEST] execute autostart scripts from mounted [DEST]"); +} + +static const char* next_param(int curr, char** argv, int argc) { + int j = curr + 1; + if(j >= argc) + return NULL; + if(argv[j][0] == '-') + return NULL; + return argv[j]; +} + +int main(int argc, char** argv) { + if(argc == 1) { + perform_autostart(false); + return 0; + } + + const char *a, *media = NULL; + bool safe = false; + + for(int i = 1; i < argc; i++) { + a = argv[i]; + if(CHECK_ARGV(a, "-h", "--help")) { + help(); + return 0; + } + + if(CHECK_ARGV(a, "-s", "--safe")) { + safe = true; + } else if(CHECK_ARGV(a, "-m", "--media")) { + media = next_param(i, argv, argc); + if(!media) { + puts("Missing media parameter"); + return 1; + } + } else { + printf("Unknown '%s' parameter. Run 'ede-autostart -h' for options\n", a); + return 1; + } + } + + if(media == NULL) + perform_autostart(safe); + return 0; +} diff --git a/evoke/ede-startup.conf b/evoke/ede-startup.conf index b78eb73..4fa5e7a 100644 --- a/evoke/ede-startup.conf +++ b/evoke/ede-startup.conf @@ -1,6 +1,6 @@ -# ede-startup configuration sample +# default ede-startup configuration [Startup] - start_order = edewm,ede-desktop,ede-panel,emountd,xscreensaver + start_order = edewm,ede-desktop,ede-panel,emountd,xscreensaver,autostart splash_theme = scape [edewm] @@ -27,3 +27,8 @@ exec = xscreensaver -nosplash icon = xscreensaver.png description = screensaver + +[autostart] + exec = ede-autostart + icon = autostart.png + description = local programs diff --git a/evoke/evoke.cpp b/evoke/evoke.cpp index 783a257..5192f8b 100644 --- a/evoke/evoke.cpp +++ b/evoke/evoke.cpp @@ -22,7 +22,6 @@ #include #include "EvokeService.h" -#include "Autostart.h" EDELIB_NS_USING(run_async) @@ -48,16 +47,12 @@ static void help(void) { puts(" -s, --startup run in startup mode"); puts(" -n, --no-splash do not show splash screen in startup mode"); puts(" -d, --dry-run run in startup mode, but don't execute anything"); - puts(" -a, --autostart read autostart directory and run all items"); - puts(" -u, --autostart-safe read autostart directory and display dialog what will be run\n"); } int main(int argc, char** argv) { bool do_startup = false; bool do_dryrun = false; bool show_splash = true; - bool do_autostart = false; - bool do_autostart_safe = false; if(argc > 1) { const char* a; @@ -73,10 +68,6 @@ int main(int argc, char** argv) { do_dryrun = true; else if(CHECK_ARGV(a, "-n", "--no-splash")) show_splash = false; - else if(CHECK_ARGV(a, "-a", "--autostart")) - do_autostart = true; - else if(CHECK_ARGV(a, "-u", "--autostart-safe")) - do_autostart_safe = true; else { printf("Unknown parameter '%s'. Run 'evoke -h' for options\n", a); return 1; @@ -127,9 +118,6 @@ int main(int argc, char** argv) { signal(SIGHUP, quit_signal); #endif - if(do_autostart || do_autostart_safe) - perform_autostart(do_autostart_safe); - service->start_xsettings_manager(); /* set stuff so xsettings manager can receive events */ diff --git a/evoke/splash-themes/scape/autostart.png b/evoke/splash-themes/scape/autostart.png new file mode 100644 index 0000000000000000000000000000000000000000..c3e31f162a50225838e76ca47fb56f03d7924685 GIT binary patch literal 1959 zcmV;Y2Uz%tP)EK~z|UwU=vb6xS8U|92ky-t~I@wy|9v4i4b(QsOqDm1rBP zRtc09b{`>9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ieu>zGcy_s6)5U|FS#rXI* zj$ily?+%Y+rLA}eS7YHZ>X-0*|G#i~WDHwNW&CuD86QnXa5E5})AQY)^ifJX^KFav z1E%jDKGslI{iNP%w~^Vyg)!{=@_Jmn!!OW(qREWYgCiKdlXEsT>5J&}dXvp&HR$wu z06Ev?Y_t1f}%3`M#FC84;(uOccdmD2nno#@PAV zGF!*NA3A$SBtp_ku1mJ)2(~&j^q$QfHh28~xPRK;#yqZnHKw}=)2!Jx^SG9^m+uJx0QfyU+eJ}4T3c7w zXe+Vl@@14#+!!5wJNxI(9n1cx`?(zxr`sTk;%|9Dcv2JuPSlCKD2fJIruvv9J*}SV tI`w}AmI~>=m2nbx#0(Z{{f8b3%BB6aH;?R002ovPDHLkV1m!#qU8Vp literal 0 HcmV?d00001 diff --git a/evoke/splash-themes/standard/autostart.png b/evoke/splash-themes/standard/autostart.png new file mode 100644 index 0000000000000000000000000000000000000000..c3e31f162a50225838e76ca47fb56f03d7924685 GIT binary patch literal 1959 zcmV;Y2Uz%tP)EK~z|UwU=vb6xS8U|92ky-t~I@wy|9v4i4b(QsOqDm1rBP zRtc09b{`>9m5R2ss$`S8n>6Z&wi5BmaUrErMWslI3e>o0qfnZXMg>BIi7SQi0!>EV|Tay)7EB;Ee#;H_a5vxHW<4V zr7VzS>}G_r_QP*Ud|S`=u)Ev#t;1)1fuzd3F~+=c#zHB^q8Y{>`^{go`fne)!R_hU z@o4~yrhquzwj)2;M7h5w{pf4za z-UudcjYnr@W*%oA*OkRGz%7~@k1Jkc&>@~>$S4d{Wk^wmBn7_ng(jWnxpup(a&xlT zscH-i0MGLP(^9{Hu#|8rnxIr=MrB@*QWOw4K+zUP&%guPCm~?~wEG6|MG_fB z(`*@aDXqdmMFI`80PM2?cmq(~J<0O8bb@T?618^SGq> z`bB?2;&j^pY;Rq+>Xny&ysIpdUOs?HB&fG?(D4Ku0Th+tsxQXc4j#WHQ~GPA|Jm1y z0uZOWvbv(|#m!9(JGO0DS=Q26WpG&Z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