From c29767aeccc1e6d9b36a9340142bae999f0d1c00 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 18 Oct 2026 11:24:25 +0200 Subject: feat(rofi): ssh menu as a grid of host cards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rofi's ssh mode shows the alias only. blackpearl-sshmenu.sh now reads ~/.ssh/config itself and feeds dmenu two-line cards: the alias, then "user · address" with the user only where the config sets one. ssh.rasi lays them out 4x3 under an "SSH:" header lifted out of the inputbar. The script moves into bin/ under the name hypr-theme's keybinding calls, and install.sh links it and the theme like the other menus. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 +- bin/blackpearl-sshmenu.sh | 28 +++++++++++++++++++++++++ install.sh | 4 ++-- rofi/udt/ssh.rasi | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 3 deletions(-) create mode 100755 bin/blackpearl-sshmenu.sh create mode 100644 rofi/udt/ssh.rasi diff --git a/AGENTS.md b/AGENTS.md index c146368..51835bc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,7 +15,7 @@ the working config cannot drift from what is committed. Everything outside the record of what changed and where the backups are. The rofi menus' launch scripts (`udt-powermenu.sh`, `udt-launcher.sh`, -`qar-scrotmenu.sh`) live in `bin/` and are symlinked into `~/bin/` under the +`qar-scrotmenu.sh`, `blackpearl-sshmenu.sh`) live in `bin/` and are symlinked into `~/bin/` under the names hypr-theme's keybindings call. They used to sit loose in `~/bin/`, so the themes were tracked and the only things that open them were not. diff --git a/bin/blackpearl-sshmenu.sh b/bin/blackpearl-sshmenu.sh new file mode 100755 index 0000000..a94217e --- /dev/null +++ b/bin/blackpearl-sshmenu.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# SSH menu: the hosts in ~/.ssh/config as cards, rofi themed by udt. +# Copyright (C) 2026 Danilo M. +# Licensed under the GNU General Public License v2 only. + +# rofi's own ssh mode shows the alias only, so the config is read here. +# ponytail: plain "Keyword value" lines in ~/.ssh/config only; Include and +# Match are not followed, wildcard Host patterns are skipped. +mapfile -t hosts < <(awk ' + function flush() { if (name != "") print name "\t" user "\t" addr } + tolower($1) == "host" { flush(); name = ($2 ~ /[*?]/) ? "" : $2; user = ""; addr = $2 } + tolower($1) == "hostname" { addr = $2 } + tolower($1) == "user" { user = $2 } + END { flush() }' ~/.ssh/config) + +# Two lines a card: the alias, then "user · address" with the user only where +# the config sets one. Entries are joined on "|" so each can hold a newline. +entries=() +for h in "${hosts[@]}"; do + IFS=$'\t' read -r name user addr <<< "$h" + entries+=("$name +${user:+$user · }$addr") +done + +i=$(IFS='|'; printf '%s' "${entries[*]}" | rofi -dmenu -i -markup-rows \ + -sep '|' -eh 2 -format i -p '󰆍 SSH:' -theme ~/.config/rofi/udt/ssh.rasi) || exit +name=${hosts[i]%%$'\t'*} +exec rofi-sensible-terminal -e ssh "$name" diff --git a/install.sh b/install.sh index 7ac2c91..8ca71db 100755 --- a/install.sh +++ b/install.sh @@ -84,7 +84,7 @@ fi # Theme files are symlinked individually; accent.rasi is NOT, it points at the # generated file in the wal cache instead. -for f in palette.rasi common.rasi menu.rasi list.rasi grid.rasi powermenu.rasi confirm.rasi screenshot.rasi; do +for f in palette.rasi common.rasi menu.rasi list.rasi grid.rasi powermenu.rasi confirm.rasi screenshot.rasi ssh.rasi; do ln -sfn "$repo/rofi/udt/$f" "$target/$f" done @@ -125,7 +125,7 @@ ln -sfn "$HOME/.cache/udt/colors.json" "$HOME/.cache/wal/colors.json" # The rofi menus are bound by name in hypr-theme's keybindings, so they keep # the names they had when they lived loose in ~/bin. -for f in udt-accent udt-grub udt-keyboard udt-steps udt-palette udt-machine-name udt-powermenu.sh udt-launcher.sh qar-scrotmenu.sh; do +for f in udt-accent udt-grub udt-keyboard udt-steps udt-palette udt-machine-name udt-powermenu.sh udt-launcher.sh qar-scrotmenu.sh blackpearl-sshmenu.sh; do ln -sfn "$repo/bin/$f" "$HOME/bin/$f" done diff --git a/rofi/udt/ssh.rasi b/rofi/udt/ssh.rasi new file mode 100644 index 0000000..4c8a88e --- /dev/null +++ b/rofi/udt/ssh.rasi @@ -0,0 +1,52 @@ +/* + * udt ssh layout: the hosts as a searchable 4x3 grid of cards. + * Copyright (C) 2026 Danilo M. + * Licensed under the GNU General Public License v2 only. + * + * Fed by blackpearl-sshmenu.sh, two lines a card: the alias in bold, then + * "user · address" dimmed with fgalpha rather than a colour, so it still + * reads on the accent when selected. + */ + +@import "common.rasi" + +window { + width: 1100px; + anchor: center; + location: center; + padding: 20px; +} + +/* The prompt is lifted out of the inputbar to sit above it as a header. */ +mainbox { + children: [ prompt, inputbar, listview ]; + spacing: 16px; +} + +prompt { + font: "Noto Sans Bold 15"; + text-color: @text; + padding: 0 4px; +} + +listview { + columns: 4; + lines: 3; + fixed-height: true; + spacing: 12px; + flow: horizontal; +} + +/* Text only: the element spacing otherwise reserves a gap for the icon. */ +element { + children: [ element-text ]; + padding: 20px 12px; + border-radius: 12px; + background-color: @surface0; +} + +element-text { + font: "Noto Sans 13"; + horizontal-align: 0.5; + vertical-align: 0.5; +} -- cgit v1.2.3