Skip to content

Commit

Permalink
Improve autostart
Browse files Browse the repository at this point in the history
  • Loading branch information
thjaeger committed Feb 19, 2013
1 parent 5f081c8 commit e6bd3eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ easystroke.desktop: easystroke.desktop.in $(MOFILES)

desktop.c: easystroke.desktop
echo "const char *desktop_file = \"\\" > $@
sed 's/Exec=easystroke/Exec=%s/' $< | sed 's/"/\\"/g' | sed 's/.*/&\\n\\/' >> $@
sed 's/Exec=easystroke/Exec=%1$$s/' $< | sed 's/"/\\"/g' | sed 's/.*/&\\n\\/' >> $@
echo "\";" >> $@

po/POTFILES.in: $(CCFILES) $(HFILES)
Expand Down
11 changes: 7 additions & 4 deletions prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
#include "main.h"
#include "grabber.h"
#include <glibmm/i18n.h>
#include <sys/stat.h>

#include <set>
#include <iostream>

extern const char *desktop_file;

class Check : private Base {
IO<bool> &io;
Gtk::CheckButton *check;
Expand Down Expand Up @@ -183,9 +186,6 @@ const Combo<TimeoutType>::Info timeout_info_exp[] = {

Source<bool> autostart_ok(true);

#include <sys/stat.h>
extern const char *desktop_file;

class Autostart : public IO<bool>, private Base {
bool a;
std::string filename;
Expand All @@ -208,8 +208,11 @@ class Autostart : public IO<bool>, private Base {
virtual bool get() const { return a; }
virtual void notify() {
if (a) {
char path[256] = "easystroke";
readlink("/proc/self/exe", path, sizeof(path));

FILE *file = fopen(filename.c_str(), "w");
if (!file || fprintf(file, desktop_file, "easystroke") == -1)
if (!file || fprintf(file, desktop_file, path) == -1)
autostart_ok.set(false);
if (file)
fclose(file);
Expand Down

0 comments on commit e6bd3eb

Please sign in to comment.