#!/bin/bash
### "config"
suggestions=(im py tex qb doc vm bsys mail conf dev ssh)
sep="-" # alternatively e.g. ": "
dmenu="rofi -dmenu"
old_name=$(herbstclient attr tags.focus.name)
prefix=${old_name%%$sep*}
prompt="Rename $prefix"
if [[ "$old_name" == *"$sep"* ]]; then
old_suffix=${old_name#*$sep}
prompt+=" ($old_suffix)"
suggestions=("(clear)" "${suggestions[@]}")
fi
new_suffix=$(printf "%s\n" "${suggestions[@]}" | $dmenu -p "$prompt")
case "$new_suffix" in
"") exit 0 ;;
"(clear)") new_name="$prefix" ;;
*) new_name="$prefix$sep$new_suffix" ;;
esac
herbstclient try merge_tag "$new_name" # It might exist already
output=$(herbstclient attr tags.focus.name "$new_name" 2>&1)
if [[ $? != 0 ]]; then
notify-send -u critical "hlwm-namenstag" \
"<i>Failed to rename \"$old_name\" -> \"$new_name\"</i><br><br>$output"
fi
herbstclient emit_hook tag_flags # Workaround for broken barpyrus
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}