From b690c975dd84c6ee9595dfd667e37622504568a8 Mon Sep 17 00:00:00 2001 From: B Stack Date: Tue, 17 Mar 2020 14:52:46 -0400 Subject: add bunch of things fix #1 add desktop file and xdg autostart file fix #2 add Makefile use make deplist move readme to src/.../doc add man pages --- .gitignore | 9 ++ README.md | 32 +---- src/Makefile | 98 +++++++++++++ .../xdg/autostart/keyboard-leds-trayicons.desktop | 11 ++ src/usr/bin/keyboard-leds-trayicons | 158 +++++++++++++++++++++ src/usr/bin/keyboard-leds-trayicons.sh | 157 -------------------- .../applications/keyboard-leds-trayicons.desktop | 11 ++ .../share/doc/keyboard-leds-trayicons/README.md | 30 ++++ .../share/man/man1/keyboard-leds-trayicons.1.md | 18 +++ .../man/man5/keyboard-leds-trayicons.conf.5.md | 38 +++++ 10 files changed, 375 insertions(+), 187 deletions(-) create mode 100644 .gitignore create mode 100644 src/Makefile create mode 100644 src/etc/xdg/autostart/keyboard-leds-trayicons.desktop create mode 100755 src/usr/bin/keyboard-leds-trayicons delete mode 100755 src/usr/bin/keyboard-leds-trayicons.sh create mode 100644 src/usr/share/applications/keyboard-leds-trayicons.desktop create mode 100644 src/usr/share/doc/keyboard-leds-trayicons/README.md create mode 100644 src/usr/share/man/man1/keyboard-leds-trayicons.1.md create mode 100644 src/usr/share/man/man5/keyboard-leds-trayicons.conf.5.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e1c82e --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.2019-* +*.swp +__pycache__ +*debhelper* +debian/keyboards-leds-trayicons/ +debian/files +*.substvars +gitmessage +debian diff --git a/README.md b/README.md index b1b727e..cc6414f 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,2 @@ -# Readme for keyboard-leds-trayicons - -This tool, written in POSIX shell, places two icons in the notification area (aka system tray), that substitute for the keyboard LEDs for Capslock and Numlock. - -## How to configure -You can set environment variable `KLT_CONF` to point to a config file, which gets loaded in a style similar to dot-sourcing a shell script. Existing environment variables will be preserved. `Keyboard-leds-trayicons` will already load the global values from `/etc/keyboard-leds-trayicons.conf` and from your user settings in `$HOME/.config/keyboard-leds-trayicons.conf`. - -Here is example config file. - - KLT_CAPS_ON_ICON=capslock-on - KLT_CAPS_OFF_ICON=capslock-off - KLT_NUM_ON_ICON=numlock-on - KLT_NUM_OFF_ICON=numlock-off - -As a side effect of using `mktrayicon`, you can use an icon name that follows the [xdg spec](https://www.freedesktop.org/wiki/Specifications/icon-theme-spec/) or you can point to a specific filename. This project includes some simple letter icons in svg format. - -## Project license -[CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) - -## Dependencies -Package manager | packages ---------------- | ------------------------------------------------------------------ -binary name | [mktrayicon](https://gitlab.com/bgstack15/mktrayicon), awk, xset -deb | [mktrayicon](https://build.opensuse.org/package/show/home:bgstack15/mktrayicon), mawk | gawk, x11-xserver-utils -rpm | undefined - -## Credits -Bundled icons are used under license from Icon8. -* little `c`: [https://visualpharm.com/free-icons/c%20letter-595b40b65ba036ed117d1027](https://visualpharm.com/free-icons/c%20letter-595b40b65ba036ed117d1027) -* License for icons: Use for free, but link to [icons8](https://icons8.com/license) +# Overview for keyboard-leds-trayicons +See the [full readme](src/usr/share/doc/keyboard-leds-trayicons/README.md) farther down in the source tree. diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..2535ac7 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,98 @@ +# File: Makefile for keyboard-leds-trayicons +# Location: keyboard-leds-trayicons source package +# Author: bgstack15 +# Startdate: 2020-03-17 +# Title: Makefile for keyboard-leds-trayicons source package +# Purpose: To use traditional Unix make utility +# History: +# Usage: +# Reference: +# https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile/26339924#26339924 +# https://stackoverflow.com/questions/19105241/how-do-you-conditionally-call-a-target-based-on-a-target-variable-makefile/19107231#19107231 +# https://stackoverflow.com/questions/5917576/sort-a-text-file-by-line-length-including-spaces +# https://superuser.com/questions/352289/bash-scripting-test-for-empty-directory/667100#667100 +# bgscripts and logout-manager Makefile +# Improve: +# Document: +# Includes a nice way to dynamically generate dependencies as self-reported by all the files. +# Dependencies: + +APPNAME = keyboard-leds-trayicons +APPVERSION = 0.0.2 +SRCDIR = $(CURDIR) +prefix = /usr +SYSCONFDIR = $(DESTDIR)/etc +BINDIR = $(DESTDIR)$(prefix)/bin +SHAREDIR = $(DESTDIR)$(prefix)/share +DOCDIR = $(SHAREDIR)/doc/${APPNAME} +MANDIR = $(SHAREDIR)/man +APPSDIR = $(SHAREDIR)/applications +ICONDIR = $(SHAREDIR)/icons +SYSCONFDIR = $(DESTDIR)/etc +XDGAUTODIR = $(SYSCONFDIR)/xdg/autostart + +awkbin :=$(shell which awk) +cpbin :=$(shell which cp) +echobin :=$(shell which echo) +findbin :=$(shell which find) +grepbin :=$(shell which grep) +installbin :=$(shell which install) +lnbin :=$(shell which ln) +rmbin :=$(shell which rm) +sedbin :=$(shell which sed) +sortbin :=$(shell which sort) +trbin :=$(shell which tr) +truebin :=$(shell which true) +uniqbin :=$(shell which uniq) +xargsbin :=$(shell which xargs) +md2manbin :=$(shell which go-md2man) +gzipbin :=$(shell which gzip) + +SEPARATOR ?=, + +all: + ${echobin} "No compilation in this package." + +.PHONY: clean install uninstall list deplist deplist_opts + +list: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | ${awkbin} -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | ${sortbin} | ${grepbin} -E -v -e '^[^[:alnum:]]' -e '^$@$$' + +deplist: + @if test -z "$(DISTRO)" ; then ${echobin} "Please run \`make deplist\` with DISTRO= one of: `make deplist_opts 2>&1 1>/dev/null | ${xargsbin}`. Aborted." ; exit 1 ; fi + @${grepbin} -h --exclude='Makefile' --exclude-dir='doc' -A5 -riIE dependencies $(SRCDIR) | ${awkbin} -v 'distro=$(DISTRO)' 'tolower($$0) ~ distro {$$1="";$$2="";print}' | ${trbin} ',' '\n' | ${sedbin} -r -e 's/^\s*//;' -e 's/\*$$//;' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/$$/$(SEPARATOR)/' | ${xargsbin} + +deplist_opts: + @${echobin} "devuan" 1>&2 + +install: install_files install_man + +install_files: + @${echobin} Installing files to ${DESTDIR} + ${installbin} -d ${SYSCONFDIR} ${BINDIR} ${DOCDIR} \ + ${APPSDIR} ${ICONDIR}/hicolor/scalable/status ${XDGAUTODIR} + ${installbin} -m 0644 -t ${SYSCONFDIR} ${SRCDIR}/etc/*.* + ${installbin} -m 0755 -t ${BINDIR} ${SRCDIR}/usr/bin/* + ${installbin} -m 0644 -t ${ICONDIR}/hicolor/scalable/status ${SRCDIR}/usr/share/icons/hicolor/scalable/status/* + ${installbin} -m 0644 -t ${XDGAUTODIR} ${SRCDIR}/etc/xdg/autostart/* + ${installbin} -m 0644 -t ${APPSDIR} ${SRCDIR}/usr/share/applications/* + ${installbin} -m 0644 -t ${DOCDIR} ${SRCDIR}/usr/share/doc/keyboard-leds-trayicons/* + +install_man: +ifeq ($(md2manbin),) + @${echobin} Cannot install man pages, because go-md2man is not found. + @false +endif + ${installbin} -d ${MANDIR}/man1 ${MANDIR}/man5 + ${md2manbin} < ${SRCDIR}/usr/share/man/man1/keyboard-leds-trayicons.1.md | ${gzipbin} > ${MANDIR}/man1/keyboard-leds-trayicons.1.gz + ${md2manbin} < ${SRCDIR}/usr/share/man/man5/keyboard-leds-trayicons.conf.5.md | ${gzipbin} > ${MANDIR}/man5/keyboard-leds-trayicons.conf.5.gz + +uninstall: + @${echobin} SRCDIR=${SRCDIR} + ${rmbin} -f $$( ${findbin} ${SRCDIR} -mindepth 1 ! -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" ) $$( ${findbin} ${SRCDIR}/usr/share/man ! -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" -r -e 's/\.md$$/.gz/;' ) + + # remove all installed directories that are now blank. + for word in $$( ${findbin} ${SRCDIR} -mindepth 1 -type d -printf '%p\n' | ${sedbin} -r -e "s:^${SRCDIR}:${DESTDIR}:" | ${awkbin} '{ print length, $$0 }' | sort -rn | ${awkbin} '{print $$2}' ) ; do ${findbin} $${word} -mindepth 1 1>/dev/null 2>&1 | read 1>/dev/null 2>&1 || { rmdir "$${word}" 2>/dev/null || ${truebin} ; } ; done + +clean: + -${echobin} "target $@ not implemented yet! Gotta say unh." diff --git a/src/etc/xdg/autostart/keyboard-leds-trayicons.desktop b/src/etc/xdg/autostart/keyboard-leds-trayicons.desktop new file mode 100644 index 0000000..aa0fb8e --- /dev/null +++ b/src/etc/xdg/autostart/keyboard-leds-trayicons.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Categories=Utility;TrayIcon; +Comment=Show capslock and numlock indicators +Exec=/usr/bin/keyboard-leds-trayicons +Icon=capslock-on +Keywords=trayicon;capslock;numlock; +Name=Keyboard LEDs trayicons +NoDisplay=false +Terminal=false +Type=Application +X-GNOME-Autostart-Phase=WindowManager diff --git a/src/usr/bin/keyboard-leds-trayicons b/src/usr/bin/keyboard-leds-trayicons new file mode 100755 index 0000000..118a0a9 --- /dev/null +++ b/src/usr/bin/keyboard-leds-trayicons @@ -0,0 +1,158 @@ +#!/usr/bin/env sh +# File: keyboard-leds-trayicons.sh +# License: CC-BY-SA 4.0 +# Author: bgstack15 +# Startdate: 2020-02-13 15:30 +# Title: Substitute for Keyboard LED Indicators +# Purpose: For systems that do not show LEDs for capslock and numlock +# History: +# Usage: +# Reference: +# some Internet place that demonstrated how to use xset q +# some Internet place that showed how to convert the decimal to binary with awk +# get_conf comes from framework.sh +# Improve: +# provide way to change status of capslock by clicking the icon? +# Dependencies: +# raw: mktrayicon, awk, xset +# devuan: mktrayicon, mawk | gawk, x11-xserver-utils + +# little c: https://visualpharm.com/free-icons/c%20letter-595b40b65ba036ed117d1027 +# license for icons: Use for free, but link to [icons8](https://icons8.com/license) + +# CONFIG FILES +test -z "${KLT_GLOBAL_CONF}" && KLT_GLOBAL_CONF=/etc/keyboard-leds-trayicons.conf +test -z "${KLT_USER_CONF}" && KLT_USER_CONF="${HOME}/.config/keyboard-leds-trayicons.conf" +# also accept KLT_CONF + +# FUNCTIONS + +get_conf() { + # Ripped from framework.sh + # call: get_conf "${conffile}" + local _infile="$1" + local _tmpfile1="$( mktemp )" + sed -e 's/^\s*//;s/\s*$//;/^[#$]/d;s/\s*[^\]#.*$//;' "${_infile}" | grep -viE "^$" | while read _line ; + do + local _left="$( echo "${_line}" | cut -d'=' -f1 )" + eval "_thisval=\"\${${_left}}\"" + test -z "${_thisval}" && echo "${_line}" >> "${_tmpfile1}" + done + test -f "${_tmpfile1}" && { . "${_tmpfile1}" 1>/dev/null 2>&1 ; } + /bin/rm -rf "${_tmpfile1}" 1>/dev/null 2>&1 +} + +clean_keyboard_leds_trayicons() { + { test -e "${capslockicon}" && echo "q" > "${capslockicon}" ; } 1>/dev/null 2>&1 & + { test -e "${numlockicon}" && echo "q" > "${numlockicon}" ; } 1>/dev/null 2>&1 & + sleep 1 && rm -f "${capslockicon}" "${numlockicon}" "${KLT_KILLFILE}" +} + +get_led_mask() { + xset q | awk 'function d2b(d,b) {while(d) {b=d%2b;d=int(d/2)}return(b)} /LED/{print d2b($NF)}' +} + +mask_position_on() { + # call: mask_position_on "${LEDS}" "${ledposition}" + ___result="$( printf "%08d" "${1}" | tail -c "${2}" | head -c 1 )" + ___result=$(( 1 - ___result )) + return "${___result}" +} + +is_capslock_on() { + # call: get_led_mask | is_capslock_on && echo "yes" + read ___ico + mask_position_on "${___ico}" "1" +} + +is_numlock_on() { + # call: get_led_mask | is_numlock_on && echo "yes" + read ___ico + mask_position_on "${___ico}" "2" +} + +# LOAD CONFIGS +# order is important! The last one called gets precedence. +# instead of simply dot-sourcing the conf file, pass it to get_conf which only applies new values, so this process's environment is preserved +for thisconf in "${KLT_CONF}" "${KLT_USER_CONF}" "${KLT_GLOBAL_CONF}" ; +do + test -r "${thisconf}" && get_conf "${thisconf}" +done + +# DEFAULTS in case configs did not have these values +test -z "${KLT_CAPS_ON_ICON}" && KLT_CAPS_ON_ICON=capslock-on +test -z "${KLT_CAPS_OFF_ICON}" && KLT_CAPS_OFF_ICON=capslock-off +test -z "${KLT_CAPS_ON_ICON}" && KLT_CAPS_ON_ICON=numlock-on +test -z "${KLT_CAPS_OFF_ICON}" && KLT_CAPS_OFF_ICON=numlock-off +test -z "${KLT_KILLFILE}" && KLT_KILLFILE="/tmp/kill-all-leds-trayicons" + +# INITIALIZATION + +capslockicon="/var/run/user/$( id -u )/${$}.cap.icon" +numlockicon="/var/run/user/$( id -u )/${$}.num.icon" + +test "ON" = "ON" && { + mkfifo "${capslockicon}" + mkfifo "${numlockicon}" + + mktrayicon "${capslockicon}" & + mktrayicon "${numlockicon}" & + + echo "m quit,echo 'q' > ${capslockicon} ; touch "${KLT_KILLFILE}"" > "${capslockicon}" + echo "m quit,echo 'q' > ${numlockicon} ; touch "${KLT_KILLFILE}"" > "${numlockicon}" +} + +caps_status_old=-1 +num_status_old=-1 + +rm -f "${KLT_KILLFILE}" + +trap 'trap "" 2 ; touch "${KLT_KILLFILE}" ' 2 # CTRL-C + +while ! test -e "${KLT_KILLFILE}" 2>/dev/null ; +do + x="$( get_led_mask )" + caps_status_now=0 + num_status_now=0 + echo "${x}" | is_capslock_on && caps_status_now=1 + echo "${x}" | is_numlock_on && num_status_now=1 + + if test "${caps_status_now}" != "${caps_status_old}" ; + then + test -p "${capslockicon}" && case "${caps_status_now}" in + 1) + test -n "${KLT_DEBUG}" && echo "capslock on (icon file ${KLT_CAPS_ON_ICON})" 1>&2 + echo "i ${KLT_CAPS_ON_ICON}" > "${capslockicon}" + echo "t capslock on" > "${capslockicon}" + ;; + 0) + test -n "${KLT_DEBUG}" && echo "capslock off (icon file ${KLT_CAPS_OFF_ICON})" 1>&2 + echo "i ${KLT_CAPS_OFF_ICON}" > "${capslockicon}" + echo "t capslock off" > "${capslockicon}" + ;; + esac + fi + + if test "${num_status_now}" != "${num_status_old}" ; + then + test -p "${numlockicon}" && case "${num_status_now}" in + 1) + test -n "${KLT_DEBUG}" && echo "numlock on (icon file ${KLT_NUM_ON_ICON})" 1>&2 + echo "i ${KLT_NUM_ON_ICON}" > "${numlockicon}" + echo "t numlock on" > "${numlockicon}" + ;; + 0) + test -n "${KLT_DEBUG}" && echo "numlock off (icon file ${KLT_NUM_OFF_ICON})" 1>&2 + echo "i ${KLT_NUM_OFF_ICON}" > "${numlockicon}" + echo "t numlock off" > "${numlockicon}" + ;; + esac + fi + + caps_status_old="${caps_status_now}" + num_status_old="${num_status_now}" + sleep 0.75 +done + +# safety shutoff +clean_keyboard_leds_trayicons diff --git a/src/usr/bin/keyboard-leds-trayicons.sh b/src/usr/bin/keyboard-leds-trayicons.sh deleted file mode 100755 index 18ce82a..0000000 --- a/src/usr/bin/keyboard-leds-trayicons.sh +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env sh -# File: keyboard-leds-trayicons.sh -# License: CC-BY-SA 4.0 -# Author: bgstack15 -# Startdate: 2020-02-13 15:30 -# Title: Substitute for Keyboard LED Indicators -# Purpose: For systems that do not show LEDs for capslock and numlock -# History: -# Usage: -# Reference: -# some Internet place that demonstrated how to use xset q -# some Internet place that showed how to convert the decimal to binary with awk -# get_conf comes from framework.sh -# Improve: -# provide way to change status of capslock by clicking the icon? -# Dependencies: -# binaries: mktrayicon, awk, xset - -# little c: https://visualpharm.com/free-icons/c%20letter-595b40b65ba036ed117d1027 -# license for icons: Use for free, but link to [icons8](https://icons8.com/license) - -# CONFIG FILES -test -z "${KLT_GLOBAL_CONF}" && KLT_GLOBAL_CONF=/etc/keyboard-leds-trayicons.conf -test -z "${KLT_USER_CONF}" && KLT_USER_CONF="${HOME}/.config/keyboard-leds-trayicons.conf" -# also accept KLT_CONF - -# FUNCTIONS - -get_conf() { - # Ripped from framework.sh - # call: get_conf "${conffile}" - local _infile="$1" - local _tmpfile1="$( mktemp )" - sed -e 's/^\s*//;s/\s*$//;/^[#$]/d;s/\s*[^\]#.*$//;' "${_infile}" | grep -viE "^$" | while read _line ; - do - local _left="$( echo "${_line}" | cut -d'=' -f1 )" - eval "_thisval=\"\${${_left}}\"" - test -z "${_thisval}" && echo "${_line}" >> "${_tmpfile1}" - done - test -f "${_tmpfile1}" && { . "${_tmpfile1}" 1>/dev/null 2>&1 ; } - /bin/rm -rf "${_tmpfile1}" 1>/dev/null 2>&1 -} - -clean_keyboard_leds_trayicons() { - { test -e "${capslockicon}" && echo "q" > "${capslockicon}" ; } 1>/dev/null 2>&1 & - { test -e "${numlockicon}" && echo "q" > "${numlockicon}" ; } 1>/dev/null 2>&1 & - sleep 1 && rm -f "${capslockicon}" "${numlockicon}" "${KLT_KILLFILE}" -} - -get_led_mask() { - xset q | awk 'function d2b(d,b) {while(d) {b=d%2b;d=int(d/2)}return(b)} /LED/{print d2b($NF)}' -} - -mask_position_on() { - # call: mask_position_on "${LEDS}" "${ledposition}" - ___result="$( printf "%08d" "${1}" | tail -c "${2}" | head -c 1 )" - ___result=$(( 1 - ___result )) - return "${___result}" -} - -is_capslock_on() { - # call: get_led_mask | is_capslock_on && echo "yes" - read ___ico - mask_position_on "${___ico}" "1" -} - -is_numlock_on() { - # call: get_led_mask | is_numlock_on && echo "yes" - read ___ico - mask_position_on "${___ico}" "2" -} - -# LOAD CONFIGS -# order is important! The last one called gets precedence. -# instead of simply dot-sourcing the conf file, pass it to get_conf which only applies new values, so this process's environment is preserved -for thisconf in "${KLT_GLOBAL_CONF}" "${KLT_USER_CONF}" "${KLT_CONF}" ; -do - test -r "${thisconf}" && get_conf "${thisconf}" -done - -# DEFAULTS in case configs did not have these values -test -z "${KLT_CAPS_ON_ICON}" && KLT_CAPS_ON_ICON=capslock-on -test -z "${KLT_CAPS_OFF_ICON}" && KLT_CAPS_OFF_ICON=capslock-off -test -z "${KLT_CAPS_ON_ICON}" && KLT_CAPS_ON_ICON=numlock-on -test -z "${KLT_CAPS_OFF_ICON}" && KLT_CAPS_OFF_ICON=numlock-off -test -z "${KLT_KILLFILE}" && KLT_KILLFILE="/tmp/kill-all-leds-trayicons" - -# INITIALIZATION - -capslockicon="/var/run/user/$( id -u )/${$}.cap.icon" -numlockicon="/var/run/user/$( id -u )/${$}.num.icon" - -test "ON" = "ON" && { - mkfifo "${capslockicon}" - mkfifo "${numlockicon}" - - mktrayicon "${capslockicon}" & - mktrayicon "${numlockicon}" & - - echo "m quit,echo 'q' > ${capslockicon} ; touch "${KLT_KILLFILE}"" > "${capslockicon}" - echo "m quit,echo 'q' > ${numlockicon} ; touch "${KLT_KILLFILE}"" > "${numlockicon}" -} - -caps_status_old=-1 -num_status_old=-1 - -rm -f "${KLT_KILLFILE}" - -trap 'trap "" 2 ; touch "${KLT_KILLFILE}" ' 2 # CTRL-C - -while ! test -e "${KLT_KILLFILE}" 2>/dev/null ; -do - x="$( get_led_mask )" - caps_status_now=0 - num_status_now=0 - echo "${x}" | is_capslock_on && caps_status_now=1 - echo "${x}" | is_numlock_on && num_status_now=1 - - if test "${caps_status_now}" != "${caps_status_old}" ; - then - test -p "${capslockicon}" && case "${caps_status_now}" in - 1) - test -n "${KLT_DEBUG}" && echo "capslock on (icon file ${KLT_CAPS_ON_ICON})" 1>&2 - echo "i ${KLT_CAPS_ON_ICON}" > "${capslockicon}" - echo "t capslock on" > "${capslockicon}" - ;; - 0) - test -n "${KLT_DEBUG}" && echo "capslock off (icon file ${KLT_CAPS_OFF_ICON})" 1>&2 - echo "i ${KLT_CAPS_OFF_ICON}" > "${capslockicon}" - echo "t capslock off" > "${capslockicon}" - ;; - esac - fi - - if test "${num_status_now}" != "${num_status_old}" ; - then - test -p "${numlockicon}" && case "${num_status_now}" in - 1) - test -n "${KLT_DEBUG}" && echo "numlock on (icon file ${KLT_NUM_ON_ICON})" 1>&2 - echo "i ${KLT_NUM_ON_ICON}" > "${numlockicon}" - echo "t numlock on" > "${numlockicon}" - ;; - 0) - test -n "${KLT_DEBUG}" && echo "numlock off (icon file ${KLT_NUM_OFF_ICON})" 1>&2 - echo "i ${KLT_NUM_OFF_ICON}" > "${numlockicon}" - echo "t numlock off" > "${numlockicon}" - ;; - esac - fi - - caps_status_old="${caps_status_now}" - num_status_old="${num_status_now}" - sleep 0.75 -done - -# safety shutoff -clean_keyboard_leds_trayicons diff --git a/src/usr/share/applications/keyboard-leds-trayicons.desktop b/src/usr/share/applications/keyboard-leds-trayicons.desktop new file mode 100644 index 0000000..aa0fb8e --- /dev/null +++ b/src/usr/share/applications/keyboard-leds-trayicons.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Categories=Utility;TrayIcon; +Comment=Show capslock and numlock indicators +Exec=/usr/bin/keyboard-leds-trayicons +Icon=capslock-on +Keywords=trayicon;capslock;numlock; +Name=Keyboard LEDs trayicons +NoDisplay=false +Terminal=false +Type=Application +X-GNOME-Autostart-Phase=WindowManager diff --git a/src/usr/share/doc/keyboard-leds-trayicons/README.md b/src/usr/share/doc/keyboard-leds-trayicons/README.md new file mode 100644 index 0000000..b1b727e --- /dev/null +++ b/src/usr/share/doc/keyboard-leds-trayicons/README.md @@ -0,0 +1,30 @@ +# Readme for keyboard-leds-trayicons + +This tool, written in POSIX shell, places two icons in the notification area (aka system tray), that substitute for the keyboard LEDs for Capslock and Numlock. + +## How to configure +You can set environment variable `KLT_CONF` to point to a config file, which gets loaded in a style similar to dot-sourcing a shell script. Existing environment variables will be preserved. `Keyboard-leds-trayicons` will already load the global values from `/etc/keyboard-leds-trayicons.conf` and from your user settings in `$HOME/.config/keyboard-leds-trayicons.conf`. + +Here is example config file. + + KLT_CAPS_ON_ICON=capslock-on + KLT_CAPS_OFF_ICON=capslock-off + KLT_NUM_ON_ICON=numlock-on + KLT_NUM_OFF_ICON=numlock-off + +As a side effect of using `mktrayicon`, you can use an icon name that follows the [xdg spec](https://www.freedesktop.org/wiki/Specifications/icon-theme-spec/) or you can point to a specific filename. This project includes some simple letter icons in svg format. + +## Project license +[CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) + +## Dependencies +Package manager | packages +--------------- | ------------------------------------------------------------------ +binary name | [mktrayicon](https://gitlab.com/bgstack15/mktrayicon), awk, xset +deb | [mktrayicon](https://build.opensuse.org/package/show/home:bgstack15/mktrayicon), mawk | gawk, x11-xserver-utils +rpm | undefined + +## Credits +Bundled icons are used under license from Icon8. +* little `c`: [https://visualpharm.com/free-icons/c%20letter-595b40b65ba036ed117d1027](https://visualpharm.com/free-icons/c%20letter-595b40b65ba036ed117d1027) +* License for icons: Use for free, but link to [icons8](https://icons8.com/license) diff --git a/src/usr/share/man/man1/keyboard-leds-trayicons.1.md b/src/usr/share/man/man1/keyboard-leds-trayicons.1.md new file mode 100644 index 0000000..7fcc7ba --- /dev/null +++ b/src/usr/share/man/man1/keyboard-leds-trayicons.1.md @@ -0,0 +1,18 @@ +keyboard-leds-trayicons 1 "March 2020" keyboard-leds-trayicons "User Manual" +================================================================ +# NAME +keyboard-leds-trayicons - show capslock and numlock indicators in tray +# SYNOPSIS +keyboard-leds-trayicons +# DESCRIPTION +Show capslock and numlock indicator icons in the panel tray. These can substitute for the keyboard LED icons for keyboards that are missing those features. +No command-line parameters exist. +# AUTHOR +bgstack15 +# REPORTING BUGS +Bug tracker: `` +# COPYRIGHT +Copyright (C) 2020 bgstack15. License CC-BY-SA 4.0. +This is free software: you are free to change it and redistribute it. There is NO WARRANTY, to the extent permitted by law. +# SEE ALSO +keyboard-leds-trayicons.conf(5) diff --git a/src/usr/share/man/man5/keyboard-leds-trayicons.conf.5.md b/src/usr/share/man/man5/keyboard-leds-trayicons.conf.5.md new file mode 100644 index 0000000..03f56b3 --- /dev/null +++ b/src/usr/share/man/man5/keyboard-leds-trayicons.conf.5.md @@ -0,0 +1,38 @@ +keyboard-leds-trayicons.conf 5 "March 2020" keyboard-leds-trayicons "File Formats and Conventions" +================================================================ +# NAME +keyboard-leds-trayicons.conf - the configuration file for keyboard-leds-trayicons +# FILE FORMAT +The file consists of key-value pairs, and is used primarily for changing what icons are displayed in the system tray. The file will be parsed in a manner similar to shell dot-sourcing the file. + +*key*=*value* + +Icon names will be resolved according to the xdg specification for icon lookups `[1]` as they will be sent through gtk3. + +# FULL EXAMPLE + +``` +KLT_CAPS_ON_ICON=capslock-on +KLT_CAPS_OFF_ICON=capslock-off +KLT_NUM_ON_ICON=numlock-on +KLT_NUM_OFF_ICON=numlock-off +KLT_KILLFILE="/var/run/user/$( id -u )/kill-all-leds-trayicons" +``` + +# DEFAULT ORDER +The various config files, by default, are read in this order. First value defined take precedence, so once a variable is defined, it will not be used by a later file. + +1. File named in environment variable *KLT_CONF* +2. $HOME/.config/keyboad-leds-trayicons.conf +3. /etc/keyboard-leds-trayicons.conf + +# AUTHOR +bgstack15 +# REPORTING BUGS +Bug tracker: `` +# COPYRIGHT +Copyright (C) 2020 bgstack15. License CC-BY-SA 4.0. +This is free software: you are free to change it and redistribute it. There is NO WARRANTY, to the extent permitted by law. +# SEE ALSO +keyboard-leds-trayicons(1) +[1] `https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#icon_lookup` -- cgit