From 93b900394d3eb604af0ae6c41eb328ae17d7f84f Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Fri, 2 Dec 2022 15:40:49 -0500 Subject: initial commit --- src/usr/bin/arandr-trayicon | 120 +++++++++++++++++++++ src/usr/share/applications/arandr-trayicon.desktop | 9 ++ .../icons/hicolor/16x16/apps/arandr-trayicon.png | Bin 0 -> 446 bytes .../icons/hicolor/24x24/apps/arandr-trayicon.png | Bin 0 -> 714 bytes .../icons/hicolor/32x32/apps/arandr-trayicon.png | Bin 0 -> 904 bytes .../icons/hicolor/48x48/apps/arandr-trayicon.png | Bin 0 -> 1442 bytes .../hicolor/scalable/apps/arandr-trayicon.svg | 99 +++++++++++++++++ src/usr/share/man/man1/arandr-trayicons.1.txt | 24 +++++ 8 files changed, 252 insertions(+) create mode 100755 src/usr/bin/arandr-trayicon create mode 100644 src/usr/share/applications/arandr-trayicon.desktop create mode 100644 src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png create mode 100644 src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png create mode 100644 src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png create mode 100644 src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png create mode 100644 src/usr/share/icons/hicolor/scalable/apps/arandr-trayicon.svg create mode 100644 src/usr/share/man/man1/arandr-trayicons.1.txt (limited to 'src/usr') diff --git a/src/usr/bin/arandr-trayicon b/src/usr/bin/arandr-trayicon new file mode 100755 index 0000000..9a66c9e --- /dev/null +++ b/src/usr/bin/arandr-trayicon @@ -0,0 +1,120 @@ +#!/bin/sh +# File: arandr-trayicon +# Location: /usr/bin +# Author: bgstack15 +# SPDX-License-Identifer: CC-BY-SA 4.0 +# Startdate: 2022-11-16 +# Title: Substitute for Keyboard LED Indicators +# Project: arandr-trayicon +# Purpose: Easy menu for switching between preconfigured display layouts +# History: +# Usage: +# Reference: +# keyboard-leds-trayicons +# Improve: +# Dependencies: +# dep-raw: mktrayicon, awk +# dep-devuan: mktrayicon, mawk | gawk +# An admin needs to build /etc/screenlayouts/ scripts, probably: +# mirror.sh, laptop-only.sh, hdmi-only.sh, extend-desktop.sh + +# CONFIG FILES +test -z "${AT_GLOBAL_CONF}" && AT_GLOBAL_CONF=/etc/arandr-trayicon.conf +test -z "${AT_USER_CONF}" && AT_USER_CONF="${HOME}/.config/arandr-trayicon.conf" +# also accept AT_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_arandr_trayicon() { + { test -e "${arandricon}" && echo "q" > "${arandricon}" ; } 1>/dev/null 2>&1 & + sleep 1 && rm -f "${arandricon}" "${AT_KILLFILE}" +} + +mask_position_on() { + # call: mask_position_on "${LEDS}" "${ledposition}" + ___result="$( printf "%08d" "${1}" | tail -c "${2}" | head -c 1 )" + ___result=$(( 1 - ___result )) + return "${___result}" +} + +# 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 "${AT_CONF}" "${AT_USER_CONF}" "${AT_GLOBAL_CONF}" ; +do + test -r "${thisconf}" && get_conf "${thisconf}" +done + +# DEFAULTS in case configs did not have these values +# an alternative icon is org.xfce.settings.display +test -z "${AT_ICON}" && AT_ICON=arandr-trayicon +test -z "${AT_KILLFILE}" && AT_KILLFILE="/tmp/kill-arandr-trayicon" + +# INITIALIZATION + +arandricon="/var/run/user/$( id -u )/${$}.arandr.icon" + +test "ON" = "ON" && { + mkfifo "${arandricon}" + + mktrayicon -i "${AT_ICON}" "${arandricon}" & + echo "i ${AT_ICON}" | tee "${arandricon}" + # Disabled because xfce4-settings needs something extra to apply which I have not learned yet + #echo "c xfce4-display-settings --minimal" | tee "${arandricon}" + echo "c arandr" | tee "${arandricon}" + echo "t Display settings" | tee "${arandricon}" + + # Disabled because xfce4-settings needs something extra to apply which I have not learned yet + #menu_string="m quick dialog,xfce4-display-settings --minimal|full settings,xfce4-display-settings|" + menu_string="m " + # loop through admin-defined layouts + for file in /etc/screenlayouts/*.sh ; + do + test -s "${file}" && { + name="$( basename "${file}" | sed -r -e "s/\.sh$//;" )" + grep -qiE 'name ?=' "${file}" && name="$( awk -F'=' '/\<[Nn]ame\>/{print $2}' )" + menu_string="${menu_string:+${menu_string}|}${name},sh -x ${file}" + } + done + # if any user-defined layouts exist, make a separator in the menu + test -n "$( find ~/.screenlayout/*.sh -maxdepth 0 -print -quit 2>/dev/null )" && menu_string="${menu_string}|" + # loop through user-defined layouts + for file in ~/.screenlayout/*.sh ; + do + test -s "${file}" && { + name="$( basename "${file}" | sed -r -e "s/\.sh$//;" )" + grep -qiE 'name ?=' "${file}" && name="$( awk -F'=' '/\<[Nn]ame\>/{print $2}' )" + menu_string="${menu_string:+${menu_string}|}${name},sh -x ${file}" + } + done + menu_string="${menu_string:+${menu_string}|}|quit,echo 'q' > ${arandricon} ; touch \"${AT_KILLFILE}\"" + #echo "menu_string=${menu_string}" ; + echo "${menu_string}" | tee "${arandricon}" +} + +rm -f "${AT_KILLFILE}" + +trap 'trap "" 2 ; touch "${AT_KILLFILE}" ' 2 # CTRL-C + +while ! test -e "${AT_KILLFILE}" 2>/dev/null ; +do + sleep 5 +done + +# safety shutoff +clean_arandr_trayicon diff --git a/src/usr/share/applications/arandr-trayicon.desktop b/src/usr/share/applications/arandr-trayicon.desktop new file mode 100644 index 0000000..bd81e0d --- /dev/null +++ b/src/usr/share/applications/arandr-trayicon.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Arandr tray icon +Comment=Change which displays are active easily +Exec=arandr-trayicon +Terminal=false +Type=Application +Icon=display +Categories=Settings;Utility; +Keywords=display;monitor; diff --git a/src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png new file mode 100644 index 0000000..72320a1 Binary files /dev/null and b/src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png differ diff --git a/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png new file mode 100644 index 0000000..32311d0 Binary files /dev/null and b/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png differ diff --git a/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png new file mode 100644 index 0000000..7672115 Binary files /dev/null and b/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png differ diff --git a/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png new file mode 100644 index 0000000..973491c Binary files /dev/null and b/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png differ diff --git a/src/usr/share/icons/hicolor/scalable/apps/arandr-trayicon.svg b/src/usr/share/icons/hicolor/scalable/apps/arandr-trayicon.svg new file mode 100644 index 0000000..f9f8420 --- /dev/null +++ b/src/usr/share/icons/hicolor/scalable/apps/arandr-trayicon.svg @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/usr/share/man/man1/arandr-trayicons.1.txt b/src/usr/share/man/man1/arandr-trayicons.1.txt new file mode 100644 index 0000000..b645c1d --- /dev/null +++ b/src/usr/share/man/man1/arandr-trayicons.1.txt @@ -0,0 +1,24 @@ +title arandr-trayicon +section 1 +project arandr-trayicon +volume General Commands Manual +date December 2022 +===== +NAME + arandr-trayicon - system tray icon that shows links to removable media drives +SYNOPSIS + arandr-trayicon +DESCRIPTION +Arandr trayicon provides a simple menu of all arandr-generated screen layout scripts, and also admin-maintained screen layout scripts, found in directory /etc/screenlayouts/. +CONFIGURATION +No parameters for the tray icon application. You can ignore the default icon and use a custom one with environment variable AT_ICON. + +Main configuration is actually by the admin who sets any scripts in /etc/screenlayouts/, and additional per-user layouts defined with arandr. +LICENSE + GPL 3.0 +AUTHOR + +BUGS +Contribute any bug reports, patches, or comments to the author. +SEE ALSO +arandr(1) -- cgit