{"id":19686120,"url":"https://github.com/loiccoyle/thqm-rs","last_synced_at":"2025-04-29T06:31:17.377Z","repository":{"id":38085218,"uuid":"448583068","full_name":"loiccoyle/thqm-rs","owner":"loiccoyle","description":"📶 A command line utility to generate and serve a dynamic menu web page.","archived":false,"fork":false,"pushed_at":"2024-10-06T17:44:12.000Z","size":3747,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T20:53:20.605Z","etag":null,"topics":["dynamic-menu","http-server","remote-control","scripting"],"latest_commit_sha":null,"homepage":"https://loiccoyle.com/projects/thqm/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loiccoyle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-16T14:48:47.000Z","updated_at":"2024-10-10T11:27:05.000Z","dependencies_parsed_at":"2024-11-11T18:32:42.084Z","dependency_job_id":"7e7322d3-bd73-489c-9f73-71b434fe6489","html_url":"https://github.com/loiccoyle/thqm-rs","commit_stats":{"total_commits":99,"total_committers":3,"mean_commits":33.0,"dds":"0.12121212121212122","last_synced_commit":"e571c4e2bd870cb2474c717e57b729dbe71a982a"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loiccoyle%2Fthqm-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loiccoyle%2Fthqm-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loiccoyle%2Fthqm-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loiccoyle%2Fthqm-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loiccoyle","download_url":"https://codeload.github.com/loiccoyle/thqm-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251450656,"owners_count":21591407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-menu","http-server","remote-control","scripting"],"created_at":"2024-11-11T18:26:12.971Z","updated_at":"2025-04-29T06:31:16.701Z","avatar_url":"https://github.com/loiccoyle.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch3 align=\"center\"\u003ethqm\u003c/h3\u003e\n\u003ch3 align=\"center\"\u003e\u003cimg src=\"https://i.imgur.com/8VpsYG4.png\" width=\"150\"\u003e\u003c/h3\u003e\n\u003ch5 align=\"center\"\u003eA command line utility to generate and serve a dynamic menu web page.\u003c/h5\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/loiccoyle/thqm-rs/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/loiccoyle/thqm-rs/actions/workflows/ci.yml/badge.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://crates.io/crates/thqm\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/thqm.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://aur.archlinux.org/packages/thqm/\"\u003e\u003cimg src=\"https://img.shields.io/aur/version/thqm\"\u003e\u003c/a\u003e\n  \u003ca href=\"./LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20windows-informational\"\u003e\n\u003c/p\u003e\n\u003chr\u003e\n\n\u003cimg src=\"https://i.imgur.com/lYwkjzP.png\" align=\"right\" width='170px'\u003e\n\u003cimg src=\"https://i.imgur.com/ezJgbhX.png\" align=\"right\" width='170px'\u003e\n\n\u003e `thqm` takes its name from the arabic تحكم, pronounced tahakoom, meaning control.\n\n`thqm` is a nifty little command line utility. It dynamically generates a web page menu based on the provided `stdin` and outputs any selections to `stdout`.\n\nIn a sense, it functions similarly to [`dmenu`](https://tools.suckless.org/dmenu/)/[`rofi`](https://github.com/davatorium/rofi) but the menu is a web page served on the local network.\n\nThis makes it perfect to control scripts over the network.\n\n**See the [examples](./examples) folder for some example scripts.**\n\n## 📦 Installation\n\n### Manual\n\nTo compile and install manually from this repo, you'll need `rust` installed.\n\nTo compile the binary:\n\n```console\ngit clone https://github.com/loiccoyle/thqm-rs\ncd thqm-rs\ncargo build --release\n```\n\nThe compiled binary will be located at `./target/release/thqm`.\nJust place this binary somewhere in your `$PATH`.\n\nOr to install it straight from `cargo`:\n\n```console\ncargo install thqm\n```\n\nMake sure you have `cargo`'s bin folder in your `$PATH`.\n\nYou'll also need to install the [template styles](https://github.com/loiccoyle/thqm-styles) with:\n\n```console\nthqm --install-styles\n```\n\nThis will install the styles in the user data folder.\n\n### Arch linux (AUR)\n\nUsing your favourite AUR helper:\n\n```console\nparu -S thqm\n```\n\nThe installation process will install the styles system wide in the `/usr/share/thqm` folder.\n\n## 📋 Usage\n\n### CLI options\n\n`thqm` has a few command line options, when in doubt see the `--help`.\n\n\u003c!-- help start --\u003e\n\n```console\n$ thqm --help\nA simple HTTP server to serve a dynamic menu web page.\n\nthqm generates a menu based on the standard input and writes selections to standard output.\n\nSee https://github.com/loiccoyle/thqm-rs/tree/main/examples for script examples.\n\nBasic usage:\n$ echo 'Option 1\\nOption 2' | thqm -u |\n    while IFS= read -r sel; do\n      case $sel in\n      'Option 1') echo 'hello';;\n      'Option 2') echo 'world';;\n      *) echo \"$sel\";;\n      esac\n    done\n\nUsage: thqm [OPTIONS]\n\nOptions:\n  -p, --port \u003cPORT\u003e            The port to listen on [default: 8000]\n  -U, --username \u003cUSERNAME\u003e    The username to authenticate with\n  -P, --password \u003cPASSWORD\u003e    The password to authenticate with\n  -S, --separator \u003cSEPARATOR\u003e  The entry separator [default: \"\\n\"]\n  -t, --title \u003cTITLE\u003e          The page title [default: thqm]\n  -s, --style \u003cSTYLE\u003e          The page style [default: default]\n      --style-dir \u003cPATH\u003e       Specify style with its root directory\n  -Q, --qrcode                 Show the qrcode in terminal\n      --save-qrcode \u003cPATH\u003e     Save the qrcode image to file\n  -u, --url                    Show the page url\n  -o, --oneshot                Shutdown server after first selection\n  -c, --custom-input           Show custom input field\n      --list-styles            List available page styles\n      --no-shutdown            Don't allow the server to be shutdown from the page\n      --no-qrcode              Don't allow the qrcode to be shown in the page\n      --install-styles         Download and install styles to the user data directory\n  -v, --verbose...             Increase logging verbosity\n  -q, --quiet...               Decrease logging verbosity\n  -h, --help                   Print help\n  -V, --version                Print version\n```\n\n\u003c!-- help end --\u003e\n\n### Scripting\n\n`thqm` will generate a web page based on the provided `stdin`, the selected entry will be printed to `stdout`.\n\nFor this behaviour to actually be useful, we'll need to do a bit of scripting.\n\nA typical script will look something like this:\n\n```bash\n#!/bin/sh\n\n# define the handler function, i.e. what each option should do.\nhandler() {\n  while IFS= read -r event; do\n    case \"$event\" in\n    \"Option 1\")\n      # handle Option 1\n      ;;\n    \"Option 2\")\n      # handle Option 2\n      ;;\n    *)\n      # pass through thqm's output\n      echo \"$event\"\n      ;;\n    esac\n  done\n}\n\nprintf \"Option 1\\nOption 2\" | thqm \"$@\" | handler\n# ^                                 ^      ^ Pass user selections to the handler\n# │                                 └ Forward script's options to thqm\n# └ Provide the options to thqm through stdin\n```\n\n**See the [examples](./examples) folder for some example scripts.**\n\n## 🎨 Styling\n\n`thqm` has a few pre-made menu styles, see the [`thqm-styles`](https://github.com/loiccoyle/thqm-styles) repository, which can be installed to your system's user data directory with the `--install-styles` flag.\n\nTo create your own styles, follow the same file structure as the included styles.\n\n| Path                                               | Usage                                                                                                          |\n| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |\n| `{DATA_DIR}/thqm/{style_name}`                     | The name of the style is determined by the name of the style's root folder in the user data directory.         |\n| `{DATA_DIR}/thqm/{style_name}/template/index.html` | This file is the [`tera`](https://docs.rs/tera/latest/tera/) template which will be used to generate the menu. |\n| `{DATA_DIR}/thqm/{style_name}/static/`             | This directory holds static resources such as `css`, `js` and image files.                                     |\n\n\u003e The `{DATA_DIR}` directory depends on the OS:\n\u003e\n\u003e - Linux: `${XDG_DATA_HOME}`\n\u003e - MacOS: `$HOME/Library/Application Support`\n\u003e - Windows: `C:\\Users\\{USER}\\AppData\\Roaming`\n\nThe style [`tera`](https://docs.rs/tera/latest/tera/) template options are documented [here](https://docs.rs/thqm/latest/thqm/styles/struct.TemplateOptions.html).\n\nUser provided styles take priority over system wide styles.\n\nIf you want to contribute your own styles, please feel free to submit them to the [`thqm-styles`](https://github.com/loiccoyle/thqm-styles) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floiccoyle%2Fthqm-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floiccoyle%2Fthqm-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floiccoyle%2Fthqm-rs/lists"}