diff options
author | B. Stack <bgstack15@gmail.com> | 2022-12-02 15:40:49 -0500 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-12-02 15:40:49 -0500 |
commit | 93b900394d3eb604af0ae6c41eb328ae17d7f84f (patch) | |
tree | cde767442b02ba2f1a099dbb9d7e4eb27d7d1ed0 /src | |
download | arandr-trayicon-93b900394d3eb604af0ae6c41eb328ae17d7f84f.tar.gz arandr-trayicon-93b900394d3eb604af0ae6c41eb328ae17d7f84f.tar.bz2 arandr-trayicon-93b900394d3eb604af0ae6c41eb328ae17d7f84f.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 90 | ||||
-rwxr-xr-x | src/etc/screenlayouts/extend-display.sh | 3 | ||||
-rwxr-xr-x | src/etc/screenlayouts/hdmi-only.sh | 3 | ||||
-rwxr-xr-x | src/etc/screenlayouts/laptop-only.sh | 3 | ||||
-rwxr-xr-x | src/etc/screenlayouts/mirror.sh | 3 | ||||
-rw-r--r-- | src/etc/xdg/autostart/arandr-trayicon.desktop | 9 | ||||
-rwxr-xr-x | src/usr/bin/arandr-trayicon | 120 | ||||
-rw-r--r-- | src/usr/share/applications/arandr-trayicon.desktop | 9 | ||||
-rw-r--r-- | src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png | bin | 0 -> 446 bytes | |||
-rw-r--r-- | src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png | bin | 0 -> 714 bytes | |||
-rw-r--r-- | src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png | bin | 0 -> 904 bytes | |||
-rw-r--r-- | src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png | bin | 0 -> 1442 bytes | |||
-rw-r--r-- | src/usr/share/icons/hicolor/scalable/apps/arandr-trayicon.svg | 99 | ||||
-rw-r--r-- | src/usr/share/man/man1/arandr-trayicons.1.txt | 24 |
14 files changed, 363 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..0c7fa97 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,90 @@ +# File: Makefile for arandr-trayicon +# Location: arandr-trayicon source package +# Author: bgstack15 +# Startdate: 2022-12-02 +# Title: Makefile for arandr-trayicon source package +# Purpose: To use traditional Unix make utility +# History: +# Usage: +# Reference: +# Makefiles from keyboard-leds-trayicons, bgscripts +# Improve: +# Document: +# Includes a nice way to dynamically generate dependencies as self-reported by all the files. +# Dependencies: +# build-devuan: txt2man, bgscripts-core + +APPNAME = arandr-trayicon +APPVERSION = 0.0.1 +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) +txt2manwrapper :=$(shell which txt2man-wrapper) +gzipbin :=$(shell which gzip) + +SEPARATOR ?=, + +all: build_man + +.PHONY: clean install install_files build_man 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: build_man install_files + +install_files: + @ls usr/share/man/man*/*gz 1>/dev/null 2>&1 && echo "Including man pages." || : + @${echobin} Installing files to ${DESTDIR} + for td in $$( ${findbin} ${SRCDIR} -type d ! -name '.*.swp' ! -name 'Makefile' -printf '%P\n' | ${sedbin} -r -e "s:etc/sysconfig:${DEFAULTDIR}:" -e "s:${DESTDIR}/?::" ) ; do ${installbin} -m0755 -d ${DESTDIR}/$${td} ; done + for tf in $$( ${findbin} ${SRCDIR} ! -type d ! -name '.*.swp' ! -name 'Makefile' ! \( -path '*/man/*' -name '*.txt' \) ! -path '*/sysconfig/*' -printf '%P\n' ) ; do MODE=0644 ; echo "$${tf}" | grep -qE "(bin|libexec|deprecated|\/screenlayouts)\/" && MODE=0755 ; ${installbin} -m$${MODE} ${SRCDIR}/$${tf} ${DESTDIR}/$${tf} ; done + @# sysconfig/default dir + +MAN_TXT:=$(wildcard usr/share/man/man*/*.txt) +MAN_GZ:= $(subst .txt,.gz,$(MAN_TXT)) + +build_man: $(MAN_GZ) + +$(MAN_GZ): %.gz: %.txt + ${txt2manwrapper} - < $< | ${gzipbin} > $@ + +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." + -${rmbin} -f usr/share/man/man*/*.gz || : diff --git a/src/etc/screenlayouts/extend-display.sh b/src/etc/screenlayouts/extend-display.sh new file mode 100755 index 0000000..18878f3 --- /dev/null +++ b/src/etc/screenlayouts/extend-display.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Sample for Thinkpad P50s +xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --mode 1920x1080 --pos 1920x0 --rotate normal diff --git a/src/etc/screenlayouts/hdmi-only.sh b/src/etc/screenlayouts/hdmi-only.sh new file mode 100755 index 0000000..d863649 --- /dev/null +++ b/src/etc/screenlayouts/hdmi-only.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Sample for Thinkpad P50s +xrandr --output eDP-1 --off --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal diff --git a/src/etc/screenlayouts/laptop-only.sh b/src/etc/screenlayouts/laptop-only.sh new file mode 100755 index 0000000..9cb9006 --- /dev/null +++ b/src/etc/screenlayouts/laptop-only.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Sample for Thinkpad P50s +xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off diff --git a/src/etc/screenlayouts/mirror.sh b/src/etc/screenlayouts/mirror.sh new file mode 100755 index 0000000..197d4d1 --- /dev/null +++ b/src/etc/screenlayouts/mirror.sh @@ -0,0 +1,3 @@ +#!/bin/sh +# Sample for Thinkpad P50s +xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --mode 1920x1080 --pos 0x0 --rotate normal diff --git a/src/etc/xdg/autostart/arandr-trayicon.desktop b/src/etc/xdg/autostart/arandr-trayicon.desktop new file mode 100644 index 0000000..bd81e0d --- /dev/null +++ b/src/etc/xdg/autostart/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/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 Binary files differnew file mode 100644 index 0000000..72320a1 --- /dev/null +++ b/src/usr/share/icons/hicolor/16x16/apps/arandr-trayicon.png diff --git a/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png Binary files differnew file mode 100644 index 0000000..32311d0 --- /dev/null +++ b/src/usr/share/icons/hicolor/24x24/apps/arandr-trayicon.png diff --git a/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png Binary files differnew file mode 100644 index 0000000..7672115 --- /dev/null +++ b/src/usr/share/icons/hicolor/32x32/apps/arandr-trayicon.png diff --git a/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png b/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png Binary files differnew file mode 100644 index 0000000..973491c --- /dev/null +++ b/src/usr/share/icons/hicolor/48x48/apps/arandr-trayicon.png 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) |