# betterx

Small X11/XFCE utilities for screen recording. Each tool is one `.c` file plus the shared `betterx.h`.

| tool | what it does |
|---|---|
| `faceshowx` | face-cam overlay (`-p` picks camera, then monitor; `-b` blurs the background, `-i` swaps it for an image) |
| `keyshowx`  | keystroke overlay (`-m N\|all`, size hotkeys Ctrl+Alt+Shift+= / - / 0, pause Ctrl+Alt+Shift+P) |
| `zoomx`     | magnifier: `lens`, `full`, `area`, `snap` (`-i/-o` choose monitors, `-l` live) |
| `cpickx`    | colour picker with a vi-style list (`-P PLACE` = where the list opens) |
| `handrollerx` | extract / list / test / create / edit archives (libarchive; single folder for tarbombs, never overwrites) |
| `renamex`   | bulk rename with live preview, conflict checks and undo (`-u`); EXIF tokens, move/copy, chmod/touch, scripts |

## Build

    make                          # every tool whose .c file is here
    make TOOLS="zoomx cpickx"     # only these
    sudo make install             # to /usr/local/bin (PREFIX=/usr to change)

`handrollerx` needs libarchive. `handrollerx` and `renamex` ask their questions in a small built-in
menu (`bx_menu.h`, `bx_tool.h`), or on the terminal when started from one; every choice is also a flag.
`faceshowx` also links the plugin host in `faceshowx-plugins/`.

A tool is skipped (and reported at the end) if it is not in `TOOLS`, its `.c` file
is missing, or one of its libraries is not installed. Deleting a `.c` file is a
valid way to drop a tool. Keep `betterx.h`.

## Config

Everything lives in `~/.config/betterx/` (or `$XDG_CONFIG_HOME/betterx/`):
`faceshowx.conf`, `keyshowx.conf`, `zoomx.conf`, `cpickx.conf`, `handrollerx.conf`, `renamex.conf`. Each tool writes a
fully commented template there the first time it runs; uncomment a line to change it.
Run `<tool> -c` (`--config`; `renamex -C`) to see where its config is and what else it keeps; help (`-h`) is coloured on a terminal
(`NO_COLOR=1` turns it off).
Command-line options always win. The old `placement.conf` (`cpickx = ..`,
`snapshot = ..`) is still read, then overridden by the new files.

## Plugins (faceshowx)

`make plugins` builds `build/plugins/*.so`; `make install-plugins` (as your user, not root) copies them to
`~/.config/betterx/plugins/`. Each plugin gets its own `<name>.conf` there on first run.
Another plugin: put its `.c` in `faceshowx-plugins/plugins/` and add the name to `PLUGINS` in the Makefile.

## Right-click actions (file managers)

`handrollerx` writes the entries itself: Bulk rename... (renamex, listed first), Extract here... and Extract to... (archives only), Unpack here... and Unpack to... (plain folders only), Compress..., and More archive options... (`handrollerx --advanced`: a picker window for one-off choices of action, format, name, destination, subfolder and so on). "Extract here" follows your `subdir` setting. **Unpack** is the same idea for a folder that is not compressed: it moves everything inside the folder out into the folder it sits in (Unpack here..., which never makes a wrapper folder) or into one you pick (Unpack to..., `unpack_to = ask | a folder`), then removes the emptied folder; name clashes follow `exists`, and the entries use the extract icons (`--action unpack`, `--action unpack-to`; More archive options... offers both for a folder selection, with Destination and If it exists); forcing a folder (or none) and `strip_top` / `-S` live in *More archive options...*. Compression takes `-l 0..9` (`compress_level`); rar is written only if the `rar` program is installed (reading rar needs nothing extra). What the quick entries do without asking is set in `handrollerx.conf` (`extract_to`, `compress_dest`, `compress_ask_format`, `compress_ask_name`, plus `subdir`, `exists`, ...). Thunar: the thunar-archive-plugin ("Thunar archive plugin" / xfce extras) puts its own Create Archive / Extract entries above custom actions, where they cannot be reordered, and it does not use handrollerx; uninstall it if you want ours (with Bulk rename... on top) to be the only archive entries.
`make integrate` (as your user, after `sudo make install`) does it for every supported file manager found in PATH;
`make integrate FM=nemo` for one, `make unintegrate` removes only what it wrote. Supported: thunar (uca.xml, merged,
backup kept), nautilus and caja (scripts), nemo (actions), dolphin (service menus), pcmanfm / pcmanfm-qt (actions); ranger and lf (no right-click, so keys `,x` extract, `,X` extract to, `,c` compress, `,r` bulk rename, `,a` menu, added between marker lines in `rc.conf` / `lfrc`).
The same is available directly: `handrollerx --integrate auto|all|NAME`, `--unintegrate NAME`.

## handrollerx extras

- **Edit archives:** `--action add|delete|convert` (`--to ARCHIVE`) rewrite an archive safely (tar, zip, 7z; rar through the optional `rar`). The picker (`--advanced`) has the same under *Add files...*, *Delete files...* and *Convert...*.
- **Pick entries:** `-i/--include` (name, folder or glob) for extract/test, and *Extract selected files...* in the picker, which shows the archive as a tree (ticking a folder ticks its contents).
- **Passwords:** zip AES-256 with `-E/--encrypt`; encrypted archives ask for the password in a masked prompt (or set `HANDROLLERX_PASSWORD`).
- **Split / join:** `--split SIZE` writes `.001 .002 ...`; opening the first part joins them automatically.
- **Self-extracting:** format `sfx` makes a `.run` file (shell stub + tar.gz) that unpacks itself.
- **unrar fallback:** rar is read by libarchive; if that fails (rar5 oddities, encrypted headers) and `unrar` is installed it is used instead (`unrar = auto|always|never`).

## renamex extras

- **EXIF** (read by renamex itself, no library): `[exif:date]`, `[exif:date:%Y%m%d_%H%M%S]`, `[exif:camera]`, `[exif:make]`, `[exif:model]`, `[exif:lens]`, `[exif:iso]`, `[exif:width]`, `[exif:height]`. JPEG and TIFF-based files. Config `exif`, `exif_fallback`; CLI `--exif/--no-exif`; menu *More options*.
- **Move / copy:** `--move-to DIR`, `--copy-to DIR` (renamed in the destination; originals stay for copy). Undo removes copies / moves back.
- **Permissions / times:** `--chmod 644|u+x,go-w|u=rwX,go=rX`, `--touch now|exif|@EPOCH|2024-05-01 12:30`; undo restores the old values.
- **Folders:** `--recursive` replaces folders by their contents (all levels); add `--dirs` to rename the folders too.
- **Import / hand edits:** `--import FILE` (one new name per line), `--set FILE NAME`, and *Edit individual names...* in the menu (pick a file, type its name).
- **Scripts:** text files in `~/.config/betterx/namescriptx/`, one step per line using the option names without dashes (see `example.nsx`). Run with `renamex -S NAME`, or from the menu; *Save these steps as a script...* writes one for you (that is the preset feature).

## Monitors

Numbered from 1 in the order `<tool> -M` prints (same as `xrandr --listmonitors`).
Lists are `all` or `1,3`. Window placement is a number, `same`, `opposite` or `wm`.

## Look and version

- **Themes:** the renamex / handrollerx window takes `menu_theme = modern|classic` (and `menu_decorations = auto|yes|no`; classic gets the window manager's frame by default, modern none). Classic is a Windows XP style dialog: beige panel, white list box, blue selection, OK / Cancel buttons (click to select, double-click or OK to accept; the keyboard works as before). cpickx takes `theme = modern|classic` (also `--theme`); with pangocairo installed (it is, for renamex) the classic text uses a real monospace font (Lucida Console / Courier New if present, else Liberation Mono / DejaVu Sans Mono) instead of the built-in bitmaps.
- **Versions:** every tool prints `NAME x.y.z` with `--version` / `-V`. The scheme is `x.y.z`: x = release, y = feature added, z = small tweak or bug fix. The number lives in `betterx.h` (`BETTERX_VERSION`).

## One config for everything

`~/.config/betterx/betterx.conf` (made by any tool on first run) holds the settings that apply to all of them; each tool reads it first and its own file (`zoomx.conf`, `renamex.conf`, ...) overrides it.

| key | effect |
|---|---|
| `theme = modern \| classic` | look of the renamex / handrollerx dialogs, cpickx, and the window icons - so `theme = classic` is all it takes to go classic everywhere |
| `icon_style = modern \| classic \| none` | the window icon alone (default: follows `theme`); `handrollerx --icons config` applies it to the app-menu / right-click icons too |
| `decorations = auto \| yes \| no` | window frame of the renamex / handrollerx dialogs |
| `font = ...` | text font of the dialogs and of cpickx (classic default: Tahoma, falling back to DejaVu Sans) |

## Icons

Two sets, drawn as SVG: `icons/modern` (flat vector on a dark tile) and `icons/classic` (Windows XP Luna style). Each is the X11-style X over a symbol per tool (zipped folder, magnifier, text field with cursor, colour wheel, WASD keys, webcam).

- **Window icon** (what the panel and Alt-Tab show for a running tool): every tool has `icon_style = modern | classic | none` in its own config file. The pixels are compiled in, so nothing has to be installed for this.
- **App menu and right-click icons** come from the icon theme. `sudo make install` puts the style given by `ICONSTYLE` (default modern) into the system theme, writes a launcher `.desktop` per tool into `/usr/share/applications`, and keeps both styles in `PREFIX/share/betterx/icons`. To change the look without touching any `.desktop` file, run as your user `handrollerx --icons classic` (or `modern`; `none` goes back to the system ones; `config` follows `icon_style` in `handrollerx.conf`). `--integrate` applies the `icon_style` of `handrollerx.conf` too. Restart the file manager / panel afterwards.
- The right-click entries have their own variants of the handrollerx icon: Extract here (green arrow down), Extract to... (blue arrow to a bar), Compress... (orange arrows meeting); More archive options... keeps the plain handrollerx icon and Bulk rename... the renamex one. In Thunar our entries are written at the top of the custom actions, so Bulk rename... sits above your own.
- `python3 icons/gen_icons.py` regenerates the SVGs; add `--header` to rebuild `bx_icons.h` (the compiled-in pixels) after editing them.
