1f6d96325b
* Temporary drop or correct multiple packages that needed updates for x86_64. * Update volume service to deprecate hard coded paths. * system-utils and sleep to common packages. * Add weston kiosk.ini for future use. * Add DIRTY variable, if true it will not clean.
87 lines
2.3 KiB
Bash
Executable file
87 lines
2.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2020-present Shanti Gilbert (https://github.com/shantigilbert)
|
|
|
|
# THESE NEEDS TO BE CLEANED UP, MAYBE WITH CASE OR FUNCTIONS
|
|
|
|
# Source predefined functions and variables
|
|
. /etc/profile
|
|
|
|
if [ "${1}" == "toggleaudio" ];then
|
|
# Toggle audio output
|
|
CURRENTAUDIO=$(get_setting "audio.device")
|
|
case "${CURRENTAUDIO}" in
|
|
"headphone")
|
|
echo "setting speakers"
|
|
amixer cset name='Playback Path' SPK
|
|
set_setting "audio.device" "speakers"
|
|
;;
|
|
"auto"|"speakers"|*)
|
|
echo "setting headphones"
|
|
amixer cset name='Playback Path' HP
|
|
set_setting "audio.device" "headphone"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if [ "${1}" == "setaudio" ];then
|
|
# Set audio output second parameter is either headphones or speakers
|
|
case "${2}" in
|
|
"headphone")
|
|
echo "setting headphones"
|
|
amixer cset name='Playback Path' HP
|
|
set_setting "audio.device" "headphone"
|
|
;;
|
|
"auto"|"speakers"|*)
|
|
echo "setting speakers"
|
|
amixer cset name='Playback Path' SPK
|
|
set_setting "audio.device" "speakers"
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if [ "${1}" == "vol" ];then
|
|
VOLSTEP=1
|
|
if [ -n "${3}" ]; then
|
|
VOLSTEP="${3}"
|
|
fi
|
|
|
|
CURRENTVOL=$(get_setting "audio.volume")
|
|
MAXVOL=100
|
|
MINVOL=0
|
|
if [ "${2}" == "+" ]; then
|
|
STEPVOL=$(($CURRENTVOL+$VOLSTEP))
|
|
elif [ "${2}" == "-" ]; then
|
|
STEPVOL=$(($CURRENTVOL-$VOLSTEP))
|
|
else
|
|
STEPVOL=${2}
|
|
fi
|
|
[ "$STEPVOL" -ge "$MAXVOL" ] && STEPVOL="$MAXVOL"
|
|
[ "$STEPVOL" -le "$MINVOL" ] && STEPVOL="$MINVOL"
|
|
amixer set "${DEVICE_AUDIO_MIXER}" ${STEPVOL}%
|
|
alsactl store -f /storage/.config/asound.state
|
|
set_setting "audio.volume" ${STEPVOL}
|
|
fi
|
|
|
|
if [ "${1}" == "bright" ]; then
|
|
STEPS="5"
|
|
BRIGHTNESS_DEV="$(ls /sys/class/backlight)"
|
|
CURRENTBRIGHT=$(cat /sys/class/backlight/${BRIGHTNESS_DEV}/brightness)
|
|
MAXBRIGHT="100" #$(cat /sys/class/backlight/${BRIGHTNESS_DEV}/max_brightness)
|
|
MINBRIGHT="2"
|
|
if [ "${2}" == "+" ]; then
|
|
STEPBRIGHT=$(($CURRENTBRIGHT+$STEPS))
|
|
elif [ "${2}" == "-" ]; then
|
|
STEPBRIGHT=$(($CURRENTBRIGHT-$STEPS))
|
|
else
|
|
STEPBRIGHT=${2}
|
|
fi
|
|
[ "$STEPBRIGHT" -ge "$MAXBRIGHT" ] && STEPBRIGHT="$MAXBRIGHT"
|
|
[ "$STEPBRIGHT" -le "$MINBRIGHT" ] && STEPBRIGHT="$MINBRIGHT"
|
|
#echo "Setting bright to $STEPBRIGHT"
|
|
echo "${STEPBRIGHT}" > /sys/class/backlight/${BRIGHTNESS_DEV}/brightness
|
|
set_setting "system.brightness" $(cat /sys/class/backlight/${BRIGHTNESS_DEV}/brightness)
|
|
fi
|
|
|
|
|