Allow autostart programs be started without dialog
Documentation update ImagesDirectory key renamed to DataDirectory; images renamed to data to follow later changes
@ -35,12 +35,15 @@ void run_all_cb(Fl_Widget*, void* w) {
|
||||
win->run_all();
|
||||
}
|
||||
|
||||
AstartDialog::AstartDialog(unsigned int sz) : Fl_Window(370, 305, _("Autostart warning")),
|
||||
curr(0), lst_sz(sz), lst(0) {
|
||||
AstartDialog::AstartDialog(unsigned int sz, bool do_show) : Fl_Window(370, 305, _("Autostart warning")),
|
||||
curr(0), lst_sz(sz), show_dialog(do_show), lst(0) {
|
||||
|
||||
if(lst_sz)
|
||||
lst = new AstartItem[lst_sz];
|
||||
|
||||
if(!show_dialog)
|
||||
return;
|
||||
|
||||
begin();
|
||||
img = new Fl_Box(10, 10, 65, 60);
|
||||
img->image(warnpix);
|
||||
@ -77,6 +80,11 @@ void AstartDialog::add_item(const edelib::String& n, const edelib::String& e) {
|
||||
}
|
||||
|
||||
void AstartDialog::run(void) {
|
||||
if(!show_dialog) {
|
||||
run_all();
|
||||
return;
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < curr; i++)
|
||||
cbrowser->add(lst[i].name.c_str());
|
||||
|
||||
@ -88,6 +96,9 @@ void AstartDialog::run(void) {
|
||||
}
|
||||
|
||||
void AstartDialog::run_selected(void) {
|
||||
if(!show_dialog)
|
||||
return;
|
||||
|
||||
int it = cbrowser->nchecked();
|
||||
if(!it)
|
||||
return;
|
||||
|
@ -29,6 +29,7 @@ class AstartDialog : public Fl_Window {
|
||||
private:
|
||||
unsigned int curr;
|
||||
unsigned int lst_sz;
|
||||
bool show_dialog;
|
||||
AstartItem* lst;
|
||||
|
||||
Fl_Box* img;
|
||||
@ -39,7 +40,7 @@ class AstartDialog : public Fl_Window {
|
||||
Fl_Button* cancel;
|
||||
|
||||
public:
|
||||
AstartDialog(unsigned int sz);
|
||||
AstartDialog(unsigned int sz, bool do_show);
|
||||
~AstartDialog();
|
||||
|
||||
unsigned int list_size(void) { return curr; }
|
||||
|
@ -35,18 +35,18 @@
|
||||
#include <string.h> // strdup, memset
|
||||
#include <errno.h> // error codes
|
||||
|
||||
void resolve_path(const edelib::String& imgdir, edelib::String& img, bool have_imgdir) {
|
||||
if(img.empty())
|
||||
void resolve_path(const edelib::String& datadir, edelib::String& item, bool have_datadir) {
|
||||
if(item.empty())
|
||||
return;
|
||||
|
||||
const char* im = img.c_str();
|
||||
const char* i = item.c_str();
|
||||
|
||||
if(!edelib::file_exists(im) && have_imgdir) {
|
||||
img = edelib::build_filename("/", imgdir.c_str(), im);
|
||||
im = img.c_str();
|
||||
if(!edelib::file_exists(im)) {
|
||||
if(!edelib::file_exists(i) && have_datadir) {
|
||||
item = edelib::build_filename("/", datadir.c_str(), i);
|
||||
i = item.c_str();
|
||||
if(!edelib::file_exists(i)) {
|
||||
// no file, send then empty
|
||||
img.clear();
|
||||
item.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -206,18 +206,18 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
|
||||
return false;
|
||||
|
||||
char buff[1024];
|
||||
bool have_imgdir = false;
|
||||
bool have_datadir = false;
|
||||
|
||||
c.get("evoke", "ImagesDirectory", buff, sizeof(buff));
|
||||
c.get("evoke", "DataDirectory", buff, sizeof(buff));
|
||||
|
||||
// no evoke section
|
||||
if(c.error() == edelib::CONF_ERR_SECTION)
|
||||
return false;
|
||||
|
||||
edelib::String imgdir;
|
||||
edelib::String datadir;
|
||||
if(c.error() == edelib::CONF_SUCCESS) {
|
||||
imgdir = buff;
|
||||
have_imgdir = true;
|
||||
datadir = buff;
|
||||
have_datadir = true;
|
||||
}
|
||||
|
||||
edelib::String splashimg;
|
||||
@ -228,7 +228,6 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
|
||||
if(c.get("evoke", "Sound", buff, sizeof(buff)))
|
||||
sound = buff;
|
||||
|
||||
|
||||
// Startup key must exists
|
||||
if(!c.get("evoke", "Startup", buff, sizeof(buff)))
|
||||
return false;
|
||||
@ -267,9 +266,12 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
|
||||
* Now, before data is send to Splash, resolve directories
|
||||
* since Splash expects that.
|
||||
*/
|
||||
resolve_path(imgdir, splashimg, have_imgdir);
|
||||
for(ClientListIter it = clients.begin(); it != clients.end(); ++it)
|
||||
resolve_path(imgdir, (*it).icon, have_imgdir);
|
||||
resolve_path(datadir, splashimg, have_datadir);
|
||||
resolve_path(datadir, sound, have_datadir);
|
||||
|
||||
ClientListIter it, it_end;
|
||||
for(it = clients.begin(), it_end = clients.end(); it != it_end; ++it)
|
||||
resolve_path(datadir, (*it).icon, have_datadir);
|
||||
|
||||
Splash sp(no_splash, dry_run);
|
||||
sp.set_clients(&clients);
|
||||
@ -299,9 +301,11 @@ bool EvokeService::init_splash(const char* config, bool no_splash, bool dry_run)
|
||||
* contains environment name, MUST not be started/not started.
|
||||
* TryExec is same as for .desktop spec.
|
||||
*/
|
||||
void EvokeService::init_autostart(void) {
|
||||
void EvokeService::init_autostart(bool safe) {
|
||||
const char* autostart_dirname = "/autostart/";
|
||||
|
||||
edelib::String adir = edelib::user_config_dir();
|
||||
adir += "/autostart/";
|
||||
adir += autostart_dirname;
|
||||
|
||||
StringList dfiles, sysdirs;
|
||||
StringListIter it, it_end;
|
||||
@ -311,8 +315,7 @@ void EvokeService::init_autostart(void) {
|
||||
edelib::system_config_dirs(sysdirs);
|
||||
if(!sysdirs.empty()) {
|
||||
for(it = sysdirs.begin(), it_end = sysdirs.end(); it != it_end; ++it) {
|
||||
*it += "/autostart/";
|
||||
|
||||
*it += autostart_dirname;
|
||||
// append content
|
||||
edelib::dir_list((*it).c_str(), dfiles, true, false, false);
|
||||
}
|
||||
@ -339,7 +342,7 @@ void EvokeService::init_autostart(void) {
|
||||
edelib::DesktopFile df;
|
||||
edelib::String item_name;
|
||||
|
||||
AstartDialog dlg(dfiles.size());
|
||||
AstartDialog dlg(dfiles.size(), safe);
|
||||
|
||||
for(it = dfiles.begin(), it_end = dfiles.end(); it != it_end; ++it) {
|
||||
if((*it).empty())
|
||||
@ -629,11 +632,11 @@ int EvokeService::handle(const XEvent* ev) {
|
||||
if(ev->xproperty.atom == _ede_spawn) {
|
||||
char buff[1024];
|
||||
if(get_string_property_value(_ede_spawn, buff, sizeof(buff))) {
|
||||
logfile->printf("Got _EVOKE_SPAWN with %s. Starting client...\n", buff);
|
||||
logfile->printf("Got _EDE_EVOKE_SPAWN with %s. Starting client...\n", buff);
|
||||
run_program(buff);
|
||||
//heuristic_run_program(buff);
|
||||
} else {
|
||||
logfile->printf("Got _EVOKE_SPAWN with malformed data. Ignoring...\n");
|
||||
logfile->printf("Got _EDE_EVOKE_SPAWN with malformed data. Ignoring...\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ class EvokeService {
|
||||
bool setup_pid(const char* file, const char* lock);
|
||||
void setup_atoms(Display* d);
|
||||
bool init_splash(const char* config, bool no_splash, bool dry_run);
|
||||
void init_autostart(void);
|
||||
void init_autostart(bool safe);
|
||||
|
||||
int handle(const XEvent* ev);
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 163 KiB After Width: | Height: | Size: 163 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@ -27,6 +27,10 @@ Options
|
||||
Run in autostart mode. It will check 'autostart' directory and run .desktop
|
||||
files from it. This will be done according to freedesktop.org autostart specification.
|
||||
|
||||
-u, --autostart-safe::
|
||||
Same as '-a' or '--autostart' option, but display dialog with items that should
|
||||
be run.
|
||||
|
||||
-c, --config [FILE]::
|
||||
Read [FILE] as config file. This file is only used in startup mode to read
|
||||
components to be started.
|
||||
@ -71,13 +75,16 @@ Hidden = true
|
||||
---------------
|
||||
Make sure that 'Hidden' key is under '[Desktop Entry]' section.
|
||||
|
||||
By default when you are using autostart mode, it will popup window with programs that are 'registered'
|
||||
for starting, from where you can choose either to start some of them, start all of them or to start
|
||||
nothing. This is intentionally; you definitely don't want some application to be started without
|
||||
your knowledge (not to say how this can be very insecure).
|
||||
Autostart mode can be run in two ways: safe and unsafe. Safe way ('-u' or '--autostart-safe') will
|
||||
popup window with programs that are 'registered' for starting, from where you can choose either to
|
||||
start some of them, start all of them or to start nothing. On other hand, unsafe way ('-a' or '--autostart')
|
||||
will simply run all 'registered' items without any questioning (should I say that this can be very insecure).
|
||||
|
||||
These options are intentionally provided so you can choose startup policy depending on your security
|
||||
options.
|
||||
|
||||
*Startup mode* is meant to be used when EDE is starting, running each component (or program)
|
||||
from evoke.conf (or file specified with '-c' option). This configuration file must be in following form:
|
||||
from evoke.conf (or file specified with '-c' option). This configuration file must be in the following form:
|
||||
--------------
|
||||
# [evoke] section must be present
|
||||
[evoke]
|
||||
|
@ -2,7 +2,7 @@
|
||||
# main section; must be present
|
||||
[evoke]
|
||||
Startup = edewm,eiconman,eworkpanel,xscreensaver
|
||||
ImagesDirectory = images
|
||||
DataDirectory = data
|
||||
#ImagesDirectory = /home/sanel/blentavo/EDE/ede2/evoke/images
|
||||
Splash = splash-alpha1.png
|
||||
Sound = startup.ogg
|
||||
|
@ -63,7 +63,8 @@ void help(void) {
|
||||
puts(" -s, --startup run in starup mode");
|
||||
puts(" -n, --no-splash do not show splash screen in starup mode");
|
||||
puts(" -d, --dry-run run in starup mode, but don't execute anything");
|
||||
puts(" -a, --autostart read autostart directory");
|
||||
puts(" -a, --autostart read autostart directory and run all items");
|
||||
puts(" -u, --autostart-safe read autostart directory and display dialog what will be run");
|
||||
puts(" -c, --config [FILE] use FILE as config file");
|
||||
puts(" -p, --pid [FILE] use FILE to store PID number");
|
||||
puts(" -l, --log [FILE] log traffic to FILE (FILE can be stdout/stderr for console output)\n");
|
||||
@ -74,10 +75,11 @@ int main(int argc, char** argv) {
|
||||
const char* pid_file = NULL;
|
||||
const char* log_file = NULL;
|
||||
|
||||
bool do_startup = 0;
|
||||
bool do_dryrun = 0;
|
||||
bool no_splash = 0;
|
||||
bool do_autostart = 0;
|
||||
bool do_startup = 0;
|
||||
bool do_dryrun = 0;
|
||||
bool no_splash = 0;
|
||||
bool do_autostart = 0;
|
||||
bool do_autostart_safe = 0;
|
||||
|
||||
if(argc > 1) {
|
||||
const char* a;
|
||||
@ -116,6 +118,8 @@ int main(int argc, char** argv) {
|
||||
no_splash = 1;
|
||||
else if(CHECK_ARGV(a, "-a", "--autostart"))
|
||||
do_autostart = 1;
|
||||
else if(CHECK_ARGV(a, "-u", "--autostart-safe"))
|
||||
do_autostart_safe = 1;
|
||||
else {
|
||||
printf("Unknown parameter '%s'. Run '"APPNAME" -h' for options\n", a);
|
||||
return 1;
|
||||
@ -156,8 +160,8 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if(do_autostart) {
|
||||
service->init_autostart();
|
||||
if(do_autostart || do_autostart_safe) {
|
||||
service->init_autostart(do_autostart_safe);
|
||||
}
|
||||
|
||||
service->setup_atoms(fl_display);
|
||||
|