From 270699d4eb1f1d27e2d8905cfbbf0037f07609ed Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Mon, 6 Jan 2025 12:33:18 +0100 Subject: add cursor color management --- bin/cursor | 22 ++++++++++++++++++++++ bin/cursor-linux | 13 +++++++++++++ etc/local.d/cursor.start | 7 +++++++ 3 files changed, 42 insertions(+) create mode 100755 bin/cursor create mode 100755 bin/cursor-linux create mode 100755 etc/local.d/cursor.start diff --git a/bin/cursor b/bin/cursor new file mode 100755 index 0000000..6fdbc12 --- /dev/null +++ b/bin/cursor @@ -0,0 +1,22 @@ +#!/bin/bash + +# Set cursor in xterm and compatibles. + +cursor() { + case $1 in + (r|red) cc='#f00' ;; + (n|green) cc='#5f5' ;; + (b|blue) cc='#55f' ;; + (c|cyan) cc='#0ff' ;; + (y|yellow) cc='#ff0' ;; + (m|magenta) cc='#f0f' ;; + (o|orange) cc='#f80' ;; + (k|black) cc='#111' ;; + (g|gr[ae]y) cc='#888' ;; + (w|white) cc='#eee' ;; + (*) cc=$1 ;; + esac +} + +cursor "${1:-red}" +printf '\e]12;'$cc'\e\' # set cursor color diff --git a/bin/cursor-linux b/bin/cursor-linux new file mode 100755 index 0000000..c283ccc --- /dev/null +++ b/bin/cursor-linux @@ -0,0 +1,13 @@ +#!/bin/sh + +# Set linux console cursor to a non-blinking color. + +case $1 in + (1|r|red) printf '\033[?17;0;64c' ;; + (2|b|blue) printf '\033[?17;0;16c' ;; + (3|g|green) printf '\033[?17;0;32c' ;; + (4|m|magenta) printf '\033[?17;0;80c' ;; + (5|o|orange) printf '\033[?17;0;96c' ;; + (6|c|cyan) printf '\033[?17;0;48c' ;; + (*) echo "usage: $0 blue cyan green magenta orange red" >&2; exit 2 ;; +esac diff --git a/etc/local.d/cursor.start b/etc/local.d/cursor.start new file mode 100755 index 0000000..0138d94 --- /dev/null +++ b/etc/local.d/cursor.start @@ -0,0 +1,7 @@ +#!/bin/sh + +# Set cursor color on ttys. + +for i in 1 2 3 4 5 6; do + /home/marc/bin/cursor-linux $i >> /dev/tty$i +done -- cgit v1.2.3