From 27b4aa629fe7c90e894aed718e22ef39588ae0b9 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 21 Aug 2014 11:21:28 -0600 Subject: Add shebang and set executable bit on ~/.fehbg --- src/wallpaper.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wallpaper.c b/src/wallpaper.c index 6e629dc..61eb1c3 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -29,6 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "options.h" #include "wallpaper.h" #include +#include Window ipc_win = None; Window my_ipc_win = None; Atom ipc_atom = None; @@ -450,12 +451,17 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, if (home) { FILE *fp; char *path; + struct stat s; path = estrjoin("/", home, ".fehbg", NULL); if ((fp = fopen(path, "w")) == NULL) { weprintf("Can't write to %s", path); } else { - fprintf(fp, "%s\n", fehbg); + fprintf(fp, "#!/bin/bash\n%s\n", fehbg); fclose(fp); + stat(path, &s); + if (chmod(path, s.st_mode | S_IXUSR | S_IXGRP) != 0) { + weprintf("Can't set %s as executable", path); + } } free(path); } -- cgit v1.2.3 From 821a09969f5f51f0e3a7e35f6c4f35aeb9fe497a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 21 Aug 2014 11:24:31 -0600 Subject: Swap bash for sh --- src/wallpaper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallpaper.c b/src/wallpaper.c index 61eb1c3..3e19c41 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -456,7 +456,7 @@ void feh_wm_set_bg(char *fil, Imlib_Image im, int centered, int scaled, if ((fp = fopen(path, "w")) == NULL) { weprintf("Can't write to %s", path); } else { - fprintf(fp, "#!/bin/bash\n%s\n", fehbg); + fprintf(fp, "#!/bin/sh\n%s\n", fehbg); fclose(fp); stat(path, &s); if (chmod(path, s.st_mode | S_IXUSR | S_IXGRP) != 0) { -- cgit v1.2.3