diff --git a/locale/tr/LC_MESSAGES/xcfg.po b/locale/tr/LC_MESSAGES/xcfg.po index 6e50b2d..f681872 100644 --- a/locale/tr/LC_MESSAGES/xcfg.po +++ b/locale/tr/LC_MESSAGES/xcfg.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-20 21:22+0300\n" +"POT-Creation-Date: 2024-02-21 22:39+0300\n" "PO-Revision-Date: 2024-02-20 20:36+0300\n" "Last-Translator: \n" "Language-Team: Turkish \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: src/main.c:101 src/main.c:258 +#: src/main.c:101 src/main.c:238 #, fuzzy msgid "Failed to get the home directory" msgstr "Ev dizini bulmak başarısız oldu" @@ -32,7 +32,7 @@ msgstr "%s dosyasını okumak için açmak başarısız oldu" msgid "Failed to open %s for writing" msgstr "%s dosyasını yazmak için açmak başarısız oldu" -#: src/main.c:152 src/main.c:264 +#: src/main.c:152 src/main.c:244 #, c-format msgid "Failed to write to %s" msgstr "%s dosyasına yazmak başarısız oldu" @@ -62,16 +62,16 @@ msgstr "Hayır" msgid "Add auto-startx to shell configuration?" msgstr "Otomatik-startx kabuk konfigürasyonu ekle?" -#: src/main.c:236 +#: src/main.c:250 +msgid "Configuration has been saved!" +msgstr "Konfigürasyon kaydedildi!" + +#: src/main.c:252 #, fuzzy, c-format msgid "Installing %s" msgstr "%s kuruluyor" -#: src/main.c:244 src/main.c:252 +#: src/main.c:258 #, fuzzy msgid "Installation failed" msgstr "Kurulum başarısız oldu" - -#: src/main.c:269 -msgid "Configuration has been saved!" -msgstr "Konfigürasyon kaydedildi!" diff --git a/src/main.c b/src/main.c index 7469fb7..9f9681c 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include "util.h" @@ -169,13 +169,13 @@ int main(int argc, char** argv, char** envp){ .name="XFCE4", .desc="Lightweight desktop environment for UNIX-like operating systems", .pkg="xfce4", - .cmd="startxfce4", + .cmd="startxfce4\n", }, { .name="bspwm", .desc="Tiling window manager based on binary space partitioning", .pkg="bspwm", - .cmd="bspwm" + .cmd="bspwm\n" } }; @@ -232,45 +232,32 @@ int main(int argc, char** argv, char** envp){ if(autox && !add_startx()) goto FAIL; + + char xinitrc[PATH_MAX]; + if(!joinhome(xinitrc, ".xinitrc")){ + error(_("Failed to get the home directory")); + goto FAIL; + } + + FILE* xf = fopen(xinitrc, "w"); + if(fwrite(desktops[indx].cmd, 1, strlen(desktops[indx].cmd), xf)<0){ + error(_("Failed to write to %s"), xinitrc); + fclose(xf); + goto FAIL; + } + + fclose(xf); + success(_("Configuration has been saved!")); info(_("Installing %s"), desktops[indx].name, mpi_path); char* args[] = { doas_path, "mp-install", desktops[indx].pkg, NULL }; - pid_t pid; - - if(posix_spawn(&pid, doas_path, NULL, NULL, args, envp) != 0) { + if(execvp(doas_path, args) != 0) { error(_("Installation failed")); - goto FAIL; } - int status; - waitpid(pid, &status, 0); - - if(status!=0){ - error(_("Installation failed")); - goto FAIL; - } - - char xinitrc[PATH_MAX]; - if(!joinhome(xinitrc, ".xinitrc")){ - error(_("Failed to get the home directory")); - goto FAIL; - } - - FILE* xf = fopen(xinitrc, "w"); - if(fwrite(xinitrc, 1, strlen(desktops[indx].cmd), xf)<0){ - error(_("Failed to write to %s"), xinitrc); - fclose(xf); - goto FAIL; - } - - success(_("Configuration has been saved!")); - fclose(xf); - free(doas_path); - return EXIT_SUCCESS; - FAIL: free(doas_path); return EXIT_FAILURE; diff --git a/src/util.h b/src/util.h index 197f575..07fe41b 100644 --- a/src/util.h +++ b/src/util.h @@ -1,4 +1,4 @@ -#define AUTOSTARTX "\n#auto-startx \nif [ -z '$DISPLAY' ] && [ '$XDG_VTNR' = 1 ]; then\nexec startx\nfi\n" +#define AUTOSTARTX "\n#auto-startx \nif [[ \"$(tty)\" == \"/dev/tty1\" ]] && [ -z \"$DISPLAY\" ]; then\nexec startx\nfi\n" struct Desktop { char* name;