update: Clean up the Makefile

This commit is contained in:
ngn
2024-05-01 13:07:40 +03:00
parent fd6489f13f
commit 004f5fbdcf
9 changed files with 325 additions and 72 deletions

View File

@ -1,8 +1,8 @@
#pragma once
#define C_RED "\x1b[31m"
#define C_BOLD "\x1b[1m"
#define C_BLUE "\x1b[34m"
#define C_RED "\x1b[31m"
#define C_BOLD "\x1b[1m"
#define C_BLUE "\x1b[34m"
#define C_GREEN "\x1b[32m"
#define C_RESET "\x1b[0m"

View File

@ -39,7 +39,7 @@
bool add_startx() {
bool ret = false;
char *profile = ".bash_profile";
char *profile = ".bash_profile";
char *shellenv = getenv("SHELL");
if (NULL != shellenv && endswith(shellenv, "zsh"))
profile = ".zshrc";
@ -56,8 +56,8 @@ bool add_startx() {
return ret;
}
char *line = NULL, *all = NULL;
int indx = 0;
char *line = NULL, *all = NULL;
int indx = 0;
size_t sz, len;
while ((sz = getline(&line, &len, pf)) != -1) {
@ -82,7 +82,7 @@ bool add_startx() {
}
char *startx = AUTOSTARTX;
all = realloc(all, indx + strlen(startx) + 10);
all = realloc(all, indx + strlen(startx) + 10);
for (int i = 0; i < strlen(startx); i++) {
all[indx] = startx[i];
indx++;
@ -119,27 +119,25 @@ int main(int argc, char **argv, char **envp) {
struct Desktop desktops[] = {
{
.name = "XFCE4",
.desc = _("Lightweight desktop environment for UNIX-like operating "
.name = "XFCE4",
.desc = _("Lightweight desktop environment for UNIX-like operating "
"systems"),
.pkg = "xfce4",
.cmd = "startxfce4\n",
},
.pkg = "xfce4",
.cmd = "startxfce4\n",
},
{
.name = "LXDE",
.desc = _("Free desktop environment with comparatively low resource "
.name = "LXDE",
.desc = _("Free desktop environment with comparatively low resource "
"requirements"),
.pkg = "lxde",
.cmd = "startlxde\n",
},
{.name = "bspwm",
.pkg = "lxde",
.cmd = "startlxde\n",
},
{.name = "bspwm",
.desc = _("Tiling window manager based on binary space partitioning"),
.pkg = "bspwm",
.cmd = "bspwm\n"},
{.name = "i3",
.desc = _("Improved tiling window manager"),
.pkg = "i3",
.cmd = "i3\n"}};
.pkg = "bspwm",
.cmd = "bspwm\n"},
{.name = "i3", .desc = _("Improved tiling window manager"), .pkg = "i3", .cmd = "i3\n"}
};
char *mpi_path = check_path("mp-install");
if (NULL == mpi_path) {
@ -160,7 +158,7 @@ int main(int argc, char **argv, char **envp) {
term_init();
int sz = sizeof(desktops) / sizeof(struct Desktop);
int sz = sizeof(desktops) / sizeof(struct Desktop);
ITEM **items = malloc(sizeof(ITEM *) * (sz + 1));
for (int i = 0; i < sz; i++)

View File

@ -27,7 +27,7 @@ int term_ask(char *text, ITEM **items, int sz) {
mvprintw(1, 1, "%s", text);
char line[strlen(text) + 5];
for (int i = 0; i < strlen(text); i++) {
line[i] = '=';
line[i] = '=';
line[i + 1] = '\0';
}
mvprintw(2, 1, "%s", line);
@ -49,7 +49,7 @@ int term_ask(char *text, ITEM **items, int sz) {
wrefresh(swin);
bool done = false;
int indx = 0, c = 0;
int indx = 0, c = 0;
while ((c = wgetch(swin))) {
switch (c) {
@ -80,7 +80,7 @@ int term_ask(char *text, ITEM **items, int sz) {
bool term_yn(char *text) {
char *yn[] = {_("Yes"), _("No"), NULL};
int sz = sizeof(yn) / sizeof(char *);
int sz = sizeof(yn) / sizeof(char *);
ITEM *items[sz + 1];
for (int i = 0; i < sz; i++)

View File

@ -2,6 +2,6 @@
#include <menu.h>
void term_init();
int term_ask(char *, ITEM **, int);
int term_ask(char *, ITEM **, int);
bool term_yn(char *);
void term_finish();

View File

@ -17,7 +17,9 @@ bool joinhome(char *res, char *path) {
return true;
}
bool exists(char *path) { return access(path, F_OK) == 0; }
bool exists(char *path) {
return access(path, F_OK) == 0;
}
bool endswith(const char *str, const char *suf) {
int strl = strlen(str);
@ -31,7 +33,7 @@ bool endswith(const char *str, const char *suf) {
char *check_path(char *bin) {
char *path = getenv("PATH");
char *res = NULL;
char *res = NULL;
if (NULL == path)
return NULL;

View File

@ -1,8 +1,8 @@
#pragma once
#include <stdbool.h>
#define AUTOSTARTX \
"\n#auto-startx \nif [[ \"$(tty)\" == \"/dev/tty1\" ]] && [ -z " \
#define AUTOSTARTX \
"\n#auto-startx \nif [[ \"$(tty)\" == \"/dev/tty1\" ]] && [ -z " \
"\"$DISPLAY\" ]; then\nexec startx\nfi\n"
typedef struct Desktop {
@ -12,7 +12,7 @@ typedef struct Desktop {
char *cmd;
} desktop_t;
bool exists(char *);
bool exists(char *);
char *check_path(char *);
bool joinhome(char *, char *);
bool endswith(const char *, const char *);
bool joinhome(char *, char *);
bool endswith(const char *, const char *);