aboutsummaryrefslogtreecommitdiff
path: root/src/usr
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr')
-rwxr-xr-xsrc/usr/bin/arandr-trayicon120
-rw-r--r--src/usr/share/applications/arandr-trayicon.desktop9
-rw-r--r--src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.pngbin0 -> 446 bytes
-rw-r--r--src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.pngbin0 -> 714 bytes
-rw-r--r--src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.pngbin0 -> 904 bytes
-rw-r--r--src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.pngbin0 -> 1442 bytes
-rw-r--r--src/usr/share/icons/hicolor/scalable/apps/arandr-trayicon.svg99
-rw-r--r--src/usr/share/man/man1/arandr-trayicons.1.txt24
8 files changed, 252 insertions, 0 deletions
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
--- /dev/null
+++ b/src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png
Binary files 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
--- /dev/null
+++ b/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png
Binary files 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
--- /dev/null
+++ b/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png
Binary files 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
--- /dev/null
+++ b/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png
Binary files 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 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ width="48"
+ height="48"
+ viewBox="0 0 12.7 12.7"
+ version="1.1"
+ id="svg1880"
+ inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
+ sodipodi:docname="display-settings-1.svg"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <sodipodi:namedview
+ id="namedview1882"
+ pagecolor="#ffffff"
+ bordercolor="#000000"
+ borderopacity="0.25"
+ inkscape:showpageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ inkscape:deskcolor="#d1d1d1"
+ inkscape:document-units="mm"
+ showgrid="false"
+ inkscape:zoom="8.8794676"
+ inkscape:cx="11.937653"
+ inkscape:cy="19.314221"
+ inkscape:window-width="1920"
+ inkscape:window-height="1042"
+ inkscape:window-x="1920"
+ inkscape:window-y="18"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="layer1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2464" />
+ </sodipodi:namedview>
+ <defs
+ id="defs1877">
+ <linearGradient
+ inkscape:collect="always"
+ id="linearGradient4799">
+ <stop
+ style="stop-color:#03b8fc;stop-opacity:1;"
+ offset="0"
+ id="stop4795" />
+ <stop
+ style="stop-color:#9ff9ff;stop-opacity:1;"
+ offset="1"
+ id="stop4797" />
+ </linearGradient>
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient4799"
+ id="linearGradient4801"
+ x1="10.583333"
+ y1="7.9375"
+ x2="1.3229166"
+ y2="3.96875"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <rect
+ style="fill:#808080;fill-opacity:1;stroke-width:1"
+ id="rect2462-3"
+ width="12.7"
+ height="7.9375"
+ x="-3.4968059e-07"
+ y="2.3812499" />
+ <rect
+ style="fill:url(#linearGradient4801);fill-opacity:1;stroke-width:0.999989"
+ id="rect2462"
+ width="11.1125"
+ height="6.3499999"
+ x="0.79374999"
+ y="3.175" />
+ <g
+ inkscape:label="Rendered Gears"
+ transform="matrix(8.7277819,0,0,8.7095379,6.3500008,6.3499985)"
+ id="g5795"
+ style="fill:#a56900;fill-opacity:1;stroke:#000000;stroke-width:0.04587864;stroke-dasharray:none;stroke-opacity:1" />
+ <path
+ id="path2560"
+ style="fill-opacity:0.202262;stroke-width:0.999998"
+ d="M 8.7180116,6.3499999 A 2.3680122,2.3680122 0 0 1 6.3499994,8.7180121 2.3680122,2.3680122 0 0 1 3.9819872,6.3499999 2.3680122,2.3680122 0 0 1 6.3499994,3.9819877 2.3680122,2.3680122 0 0 1 8.7180116,6.3499999 Z M 8.0824183,5.8834617 8.9091574,5.6607976 8.9499074,5.6547912 9.9240861,6.025703 V 6.674294 L 8.9499074,7.0452058 8.9091574,7.0391994 8.0824183,6.8165353 7.6211358,7.6139057 8.2277271,8.2170499 8.2532384,8.2492577 8.4184693,9.2766274 7.8556094,9.6009227 7.0466644,8.9444685 7.0314836,8.9062505 6.8113359,8.0804957 H 5.8886655 L 5.6685179,8.9062505 5.6533368,8.9444679 4.8443887,9.6009258 4.2815288,9.2766306 4.4467597,8.2492609 4.472271,8.217053 5.0788623,7.6139088 4.6175798,6.8165384 3.7908407,7.0392025 3.7500907,7.045209 2.7759121,6.6742971 V 6.0257062 l 0.9741786,-0.3709119 0.04075,0.00601 L 4.6175798,5.8834649 5.0788623,5.0860945 4.472271,4.4829503 4.4467597,4.4507424 4.2815288,3.4233727 4.8443887,3.0990774 5.6533368,3.7555353 5.6685179,3.7937528 5.8886655,4.6195076 H 6.8113359 L 7.0314836,3.7937528 7.0466647,3.7555353 7.8556127,3.0990774 8.4184725,3.4233727 8.2532417,4.4507424 8.2277304,4.4829503 7.621139,5.0860945 Z" />
+ <circle
+ style="fill:#ececec;fill-opacity:1;stroke-width:1"
+ id="path2560-6"
+ cx="6.3499994"
+ cy="6.3499999"
+ r="1.4357915" />
+ </g>
+</svg>
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
+<bgstack15@gmail.com>
+BUGS
+Contribute any bug reports, patches, or comments to the author.
+SEE ALSO
+arandr(1)
bgstack15