diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2021-07-03 21:41:08 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2021-07-03 21:41:08 -0700 |
| commit | a78619a402f3a63faa386403c068d1079780c57a (patch) | |
| tree | c7749cb004281367005a177d9168edb694791f6c | |
| parent | 1d54d6a29269d89248f65d9f2874b88c34e63691 (diff) | |
Switch from /etc/xdg/bb to /etc/bb
| -rw-r--r-- | API.md | 2 | ||||
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | bb.c | 10 | ||||
| -rw-r--r-- | types.h | 4 |
5 files changed, 15 insertions, 11 deletions
@@ -10,7 +10,7 @@ internal state. ## Helper Functions `bb` is bundled with some helper scripts for performing common tasks. These -scripts are installed to `/etc/xdg/bb/`, which is added to `bb`'s `$PATH` +scripts are installed to `/etc/bb/`, which is added to `bb`'s `$PATH` environment variable at runtime. `~/.config/bb/` is also added to the `$PATH` with higher priority, so you can override any of these scripts by putting your own version there. @@ -42,8 +42,8 @@ install: $(NAME) fi; \ [ ! "$$prefix" ] && prefix="/usr/local"; \ [ ! "$$sysconfdir" ] && sysconfdir=/etc; \ - mkdir -pv -m 755 "$$prefix/man/man1" "$$prefix/bin" "$$sysconfdir/xdg/$(NAME)" \ - && cp -rv scripts/* "$$sysconfdir/xdg/$(NAME)/" \ + mkdir -pv -m 755 "$$prefix/man/man1" "$$prefix/bin" "$$sysconfdir/$(NAME)" \ + && cp -rv scripts/* "$$sysconfdir/$(NAME)/" \ && cp -v bb.1 "$$prefix/man/man1/$(NAME).1" \ && cp -v bbcmd.1 "$$prefix/man/man1/bbcmd.1" \ && rm -f "$$prefix/bin/$(NAME)" \ @@ -58,7 +58,7 @@ uninstall: [ ! "$$prefix" ] && prefix="/usr/local"; \ [ ! "$$sysconfdir" ] && sysconfdir=/etc; \ echo "Deleting..."; \ - rm -rvf "$$prefix/bin/$(NAME)" "$$prefix/man/man1/$(NAME).1" "$$prefix/man/man1/bbcmd.1" "$$sysconfdir/xdg/$(NAME)"; \ + rm -rvf "$$prefix/bin/$(NAME)" "$$prefix/man/man1/$(NAME).1" "$$prefix/man/man1/bbcmd.1" "$$sysconfdir/$(NAME)"; \ printf "\033[1mIf you created any config files in ~/.config/$(NAME), you may want to delete them manually.\033[0m\n" .PHONY: all, clean, install, uninstall @@ -63,13 +63,13 @@ run the shell command `rm -rf file1 file2` and then tell `bb` to deselect all ## Customizing bb When `bb` launches, it first updates `bb`'s `$PATH` environment variable to -include, in order, `~/.config/bb` and `/etc/xdg/bb`. Then, `bb` will run the +include, in order, `~/.config/bb/` and `/etc/bb/`. Then, `bb` will run the command `bbstartup` (the default implementation is found at [scripts/bbstartup](scripts/bbstartup), along with other default `bb` commands). `bbstartup` will call `bbkeys` and may also set up configuration options like which columns to display and what sort order to use. All of these behaviors can be customized by creating custom local versions of these files in `~/.config/bb/`. -The default versions can be found in `/etc/xdg/bb/`. +The default versions can be found in `/etc/bb/`. You can also create temporary bindings at runtime by hitting `Ctrl-b`, pressing the key you want to bind, and then entering in a script to run (in case you @@ -117,6 +117,10 @@ void bb_browse(bb_t *bb, const char *initial_path) { if (populate_files(bb, initial_path)) clean_err("Could not find initial path: \"%s\"", initial_path); + // Emergency fallback: + bindings[0].key = KEY_CTRL_C; + bindings[0].script = strdup("kill -INT $PPID"); + bindings[0].description = strdup("Kill the bb process"); run_script(bb, "bbstartup"); check_cmdfile(bb); while (!bb->should_quit) { @@ -664,8 +668,8 @@ static void run_bbcmd(bb_t *bb, const char *cmd) } binding_t binding = {keyval, script2, memcheck(strdup(description))}; if (bindings[i].key == keyval) { - free(bindings[i].description); - free(bindings[i].script); + free((char*)bindings[i].description); + free((char*)bindings[i].script); for (; i + 1 < sizeof(bindings)/sizeof(bindings[0]) && bindings[i+1].key; i++) bindings[i] = bindings[i+1]; } @@ -1159,7 +1163,7 @@ int main(int argc, char *argv[]) getenv("XDG_CONFIG_HOME"), getenv("BBPATH"), getenv("PATH")) < 0) clean_err("Could not allocate memory for PATH"); } else { - if (asprintf(&newpath, "%s/"BB_NAME":%s/xdg/"BB_NAME":%s", + if (asprintf(&newpath, "%s/"BB_NAME":%s/"BB_NAME":%s", getenv("XDG_CONFIG_HOME"), getenv("sysconfdir"), getenv("PATH")) < 0) clean_err("Could not allocate memory for PATH"); } @@ -81,8 +81,8 @@ typedef struct bb_s { // Key bindings: typedef struct { int key; - char *script; - char *description; + const char *script; + const char *description; } binding_t; #endif |
