4 Commits
24.00 ... 24.03

4 changed files with 53 additions and 55 deletions

View File

@ -6,7 +6,7 @@ PO_FILES = $(wildcard locale/*/*/*.po)
dist/xcfg: $(SRCS) $(HEADERS) $(PO_FILES) dist/xcfg: $(SRCS) $(HEADERS) $(PO_FILES)
mkdir -p dist mkdir -p dist
gcc $(CFLAGS) $(SRCS) -o $@ -lcurses -lmenu -lm gcc $(CFLAGS) $(SRCS) -o $@ -lncurses -lmenu -lm
mkdir -p locale mkdir -p locale
xgettext -k_ -c $(SRCS) -o locale/xcfg.pot xgettext -k_ -c $(SRCS) -o locale/xcfg.pot
@for po in $(PO_DIRS) ; do \ @for po in $(PO_DIRS) ; do \
@ -20,16 +20,16 @@ dist/xcfg: $(SRCS) $(HEADERS) $(PO_FILES)
fi; \ fi; \
done done
@for po in $(PO_DIRS) ; do \ @for po in $(PO_DIRS) ; do \
msgfmt $$po/xcfg.po -o $$po/mp.mo ; \ msgfmt $$po/xcfg.po -o $$po/xcfg.mo ; \
done done
install: install:
mkdir -p $(DESTDIR)$(prefix)/bin mkdir -p $(DESTDIR)$(prefix)/bin
install -m755 dist/xcfg $(DESTDIR)$(prefix)/bin/xcfg install -m755 dist/xcfg $(DESTDIR)$(prefix)/bin/xcfg
@for po in $(PO_DIRS) ; do \ @for po in $(PO_DIRS) ; do \
echo "installing locale: $$po/mp.mo" ; \ echo "installing locale: $$po/xcfg.mo" ; \
mkdir -pv $(DESTDIR)/usr/share/$$po ; \ mkdir -pv $(DESTDIR)/usr/share/$$po ; \
cp $$po/mp.mo $(DESTDIR)/usr/share/$$po ; \ cp $$po/xcfg.mo $(DESTDIR)/usr/share/$$po ; \
done done
uninstall: uninstall:

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-20 20:59+0300\n" "POT-Creation-Date: 2024-02-22 20:30+0300\n"
"PO-Revision-Date: 2024-02-20 20:36+0300\n" "PO-Revision-Date: 2024-02-20 20:36+0300\n"
"Last-Translator: <ngn@ngn.tf>\n" "Last-Translator: <ngn@ngn.tf>\n"
"Language-Team: Turkish <gnome-turk@gnome.org>\n" "Language-Team: Turkish <gnome-turk@gnome.org>\n"
@ -17,7 +17,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/main.c:101 src/main.c:258 #: src/main.c:101 src/main.c:243
#, fuzzy #, fuzzy
msgid "Failed to get the home directory" msgid "Failed to get the home directory"
msgstr "Ev dizini bulmak başarısız oldu" msgstr "Ev dizini bulmak başarısız oldu"
@ -32,46 +32,52 @@ msgstr "%s dosyasını okumak için açmak başarısız oldu"
msgid "Failed to open %s for writing" msgid "Failed to open %s for writing"
msgstr "%s dosyasını yazmak için açmak başarısız oldu" 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:249
#, c-format #, c-format
msgid "Failed to write to %s" msgid "Failed to write to %s"
msgstr "%s dosyasına yazmak başarısız oldu" msgstr "%s dosyasına yazmak başarısız oldu"
#: src/main.c:184 #: src/main.c:164
msgid "You should use this script as a regular user, not as root!"
msgstr ""
"Bu betiği normal bir kullanıcı olarak kullanmalısınız, kök kullanıcı olarak "
"değil!"
#: src/main.c:189
#, fuzzy #, fuzzy
msgid "mp is not installed!" msgid "mp is not installed!"
msgstr "mp kurulu değil" msgstr "mp kurulu değil"
#: src/main.c:193 #: src/main.c:198
msgid "Install doas or sudo to use this script" msgid "Install doas or sudo to use this script"
msgstr "Bu betiği kullanmak için doas ya da sudo kurun" msgstr "Bu betiği kullanmak için doas ya da sudo kurun"
#: src/main.c:211 #: src/main.c:216
msgid "Choose a desktop enviroment" msgid "Choose a desktop enviroment"
msgstr "Bir masaüstü ortamı seçin" msgstr "Bir masaüstü ortamı seçin"
#: src/main.c:217 #: src/main.c:222
msgid "Yes" msgid "Yes"
msgstr "Evet" msgstr "Evet"
#: src/main.c:217 #: src/main.c:222
msgid "No" msgid "No"
msgstr "Hayır" msgstr "Hayır"
#: src/main.c:224 #: src/main.c:229
msgid "Add auto-startx to shell configuration?" msgid "Add auto-startx to shell configuration?"
msgstr "Otomatik-startx kabuk konfigürasyonu ekle?" msgstr "Otomatik-startx kabuk konfigürasyonu ekle?"
#: src/main.c:236 #: src/main.c:255
msgid "Configuration has been saved!"
msgstr "Konfigürasyon kaydedildi!"
#: src/main.c:257
#, fuzzy, c-format #, fuzzy, c-format
msgid "Installing %s" msgid "Installing %s"
msgstr "%s kuruluyor" msgstr "%s kuruluyor"
#: src/main.c:244 src/main.c:252 #: src/main.c:263
#, fuzzy #, fuzzy
msgid "Installation failed" msgid "Installation failed"
msgstr "Kurulum başarısız oldu" msgstr "Kurulum başarısız oldu"
#: src/main.c:269
msgid "Configuration has been saved!"
msgstr "Konfigürasyon kaydedildi!"

View File

@ -26,7 +26,7 @@
#include <curses.h> #include <curses.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <spawn.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <menu.h> #include <menu.h>
#include "util.h" #include "util.h"
@ -160,22 +160,27 @@ END:
} }
int main(int argc, char** argv, char** envp){ int main(int argc, char** argv, char** envp){
if(getuid()==0){
error(_("You should use this script as a regular user, not as root!"));
return EXIT_FAILURE;
}
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
textdomain("mp"); textdomain("xcfg");
struct Desktop desktops[] = { struct Desktop desktops[] = {
{ {
.name="XFCE4", .name="XFCE4",
.desc="Lightweight desktop environment for UNIX-like operating systems", .desc="Lightweight desktop environment for UNIX-like operating systems",
.pkg="xfce4", .pkg="xfce4",
.cmd="startxfce4", .cmd="startxfce4\n",
}, },
{ {
.name="bspwm", .name="bspwm",
.desc="Tiling window manager based on binary space partitioning", .desc="Tiling window manager based on binary space partitioning",
.pkg="bspwm", .pkg="bspwm",
.cmd="bspwm" .cmd="bspwm\n"
} }
}; };
@ -185,7 +190,7 @@ int main(int argc, char** argv, char** envp){
return EXIT_FAILURE; return EXIT_FAILURE;
} }
free(mpi_path); free(mpi_path);
char* doas_path = check_path("doas"); char* doas_path = check_path("doas");
if(NULL==doas_path) { if(NULL==doas_path) {
doas_path = check_path("sudo"); doas_path = check_path("sudo");
@ -232,45 +237,32 @@ int main(int argc, char** argv, char** envp){
if(autox && !add_startx()) if(autox && !add_startx())
goto FAIL; 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); info(_("Installing %s"), desktops[indx].name, mpi_path);
char* args[] = { char* args[] = {
doas_path, "mp-install", desktops[indx].pkg, NULL doas_path, "mp-install", desktops[indx].pkg, NULL
}; };
pid_t pid; if(execvp(doas_path, args) != 0) {
if(posix_spawn(&pid, doas_path, NULL, NULL, args, envp) != 0) {
error(_("Installation failed")); 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: FAIL:
free(doas_path); free(doas_path);
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -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 { struct Desktop {
char* name; char* name;