Add screensetup-* applets

This commit is contained in:
Fierelier 2023-11-18 17:00:49 +01:00
parent 9fa6213bb5
commit e1a4c03f5a
3 changed files with 46 additions and 0 deletions

35
user/applets.d/screensetup-id Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
export LANG="C"
export LC_ALL="C"
function xOutputGetList() {
local OUTPUTS="$(xrandr | grep " connected" | awk '{print $1}')"
local OUTPUTS="$(sort <<< "$OUTPUTS")"
echo "$OUTPUTS"
}
function xOutputGetEDID() {
local OUTPUT="$1"
local EDID="$(xrandr --props | awk -v OUTPUT="$OUTPUT" '/^'$OUTPUT' connected/ {flag=1; next} /EDID:/ && flag {for(i = 0; i < 8; i++) {getline; print}; flag=0}')"
local EDID="${EDID//[$'\t\r\n ']}"
echo "$EDID"
}
function xOutputGetUUID() {
local EDID="$1"
echo "${EDID:16:20}" # https://en.wikipedia.org/wiki/Extended_Display_Identification_Data#Structure,_version_1.4
}
function md5() {
local HASH=($(echo "$1" | md5sum))
echo $HASH
}
output_list="$(xOutputGetList)"
setup=""
for output in $output_list; do
EDID="$(xOutputGetEDID "$output")"
UUID="$(xOutputGetUUID "$EDID")"
setup="$setup;$output:$UUID"
done
echo "$(md5 "$setup")"

View File

@ -0,0 +1,8 @@
#!/bin/bash
SSETUP="$de_distro.$("$de_distro" screensetup-id)"
set +e
autorandr --load "$SSETUP"
if ! [ "$?" = "0" ]; then
set -e
xrandr --auto
fi

View File

@ -0,0 +1,3 @@
#!/bin/bash
SSETUP="$de_distro.$("$de_distro" screensetup-id)"
autorandr --save "$SSETUP" --force