Start work on display adjustment feature. Thanks to @christianhaitian for the idea and reference implementation.
This commit is contained in:
parent
79d3987b31
commit
f00cde619b
3 changed files with 119 additions and 1 deletions
103
packages/jelos/sources/scripts/display
Executable file
103
packages/jelos/sources/scripts/display
Executable file
|
@ -0,0 +1,103 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (C) 2023-present Fewtarius
|
||||
|
||||
. /etc/profile
|
||||
|
||||
# ARGS:
|
||||
#
|
||||
# 1 - property to adjust (contrast/saturation/hue)
|
||||
# 2 - up/down or a defined value
|
||||
|
||||
PROPERTY=${1}
|
||||
NEWVAL=${2}
|
||||
|
||||
# Command usage:
|
||||
# drm_tool set /dev/dri/card0 133 saturation value
|
||||
|
||||
# Define the basics
|
||||
MIN=1
|
||||
MAX=100
|
||||
STEP=1
|
||||
DEFAULTVAL=50
|
||||
|
||||
if [ ! -e /dev/dri/card0 ]
|
||||
then
|
||||
echo "ERROR: No display found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log() {
|
||||
$DEBUG && echo "Info: ${*}"
|
||||
}
|
||||
|
||||
getValue() {
|
||||
MYVAL=$(get_setting system.${1})
|
||||
if [ -n "${MYVAL}" ]
|
||||
then
|
||||
if [ "${MYVAL}" > "${MAX}" ]
|
||||
then
|
||||
MYVAL=${MAX}
|
||||
elif [ "${MYVAL}" < "${MIN}" ]
|
||||
then
|
||||
MYVAL=${MIN}
|
||||
fi
|
||||
echo ${MYVAL}
|
||||
else
|
||||
echo ${DEFAULTVAL}
|
||||
fi
|
||||
}
|
||||
|
||||
setValue() {
|
||||
log "Set (${2})"
|
||||
drm_tool set /dev/dri/card0 133 ${1} ${2}
|
||||
if [ $? = 0 ]
|
||||
then
|
||||
set_setting system.${1} ${2}
|
||||
fi
|
||||
}
|
||||
|
||||
stepUp() {
|
||||
LASTVAL=$(getValue)
|
||||
NEWVAL=$(expr ${LASTVAL} + 1)
|
||||
log "Step up (${NEWVAL})"
|
||||
setValue ${PROPERTY} ${NEWVAL}
|
||||
}
|
||||
|
||||
stepDown() {
|
||||
LASTVAL=$(getValue)
|
||||
NEWVAL=$(expr ${LASTVAL} - 1)
|
||||
log "Step down (${NEWVAL})"
|
||||
setValue ${PROPERTY} ${NEWVAL}
|
||||
}
|
||||
|
||||
restoreSettings() {
|
||||
for PROPERTY in contrast saturation hue
|
||||
do
|
||||
RESTVAL=$(getValue)
|
||||
setValue ${PROPERTY} $(RESTVAL)
|
||||
done
|
||||
}
|
||||
|
||||
case ${NEWVAL} in
|
||||
"up")
|
||||
stepUp
|
||||
;;
|
||||
"down")
|
||||
stepDown
|
||||
;;
|
||||
"restore")
|
||||
restoreSettings
|
||||
;;
|
||||
*)
|
||||
if [[ "${NEWVAL}" =~ ^[0-9] ]] && \
|
||||
[ "${NEWVAL}" -le "${MAX}" ] && \
|
||||
[ "${NEWVAL}" -ge "${MIN}" ]
|
||||
then
|
||||
setValue ${PROPERTY} ${NEWVAL}
|
||||
else
|
||||
echo "Error: Invalid value."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
15
packages/sysutils/drm_tool/package.mk
Normal file
15
packages/sysutils/drm_tool/package.mk
Normal file
|
@ -0,0 +1,15 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (C) 2023-present Fewtarius
|
||||
|
||||
PKG_NAME="drm_tool"
|
||||
PKG_VERSION="1cb5b10"
|
||||
PKG_LICENSE="GPLv3"
|
||||
PKG_SITE="https://github.com/NickCis/drm_tool"
|
||||
PKG_URL="${PKG_SITE}.git"
|
||||
PKG_DEPENDS_TARGET="toolchain"
|
||||
PKG_LONGDESC="A simple tool for getting drm info and setting properties."
|
||||
|
||||
makeinstall_target() {
|
||||
mkdir -p ${INSTALL}/usr/bin
|
||||
cp drm_tool ${INSTALL}/usr/bin
|
||||
}
|
|
@ -10,7 +10,7 @@ PKG_ARCH="any"
|
|||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="https://github.com/JustEnoughLinuxOS/emulationstation"
|
||||
PKG_URL="${PKG_SITE}.git"
|
||||
PKG_DEPENDS_TARGET="boost toolchain SDL2 freetype curl freeimage bash rapidjson SDL2_mixer fping p7zip alsa vlc splash"
|
||||
PKG_DEPENDS_TARGET="boost toolchain SDL2 freetype curl freeimage bash rapidjson SDL2_mixer fping p7zip alsa vlc drm_tool splash"
|
||||
PKG_NEED_UNPACK="busybox"
|
||||
PKG_SHORTDESC="Emulationstation emulator frontend"
|
||||
PKG_BUILD_FLAGS="-gold"
|
||||
|
|
Loading…
Reference in a new issue