Cleaned up the script files

This commit is contained in:
Michel-FK 2020-05-31 22:30:47 +02:00
parent edd0586bd3
commit 5d21e7a6f1
24 changed files with 138 additions and 132 deletions

View File

@ -1,19 +1,23 @@
#!/bin/sh
BRIGHTNESS_FILE="/etc/current_brightness"
BRIGHTNESS_FILE=/etc/current_brightness
BRIGHTNESS_DEFAULT_VALUE=100
# Check args
if [ ${#} -ne 0 ]; then
echo "Usage: $(basename ${0})"
exit 1
fi
# Sanity check: File does not exist
if [ ! -f "${BRIGHTNESS_FILE}" ]; then
#echo "error: \"${BRIGHTNESS_FILE}\" does not exist" >&2
echo ${BRIGHTNESS_DEFAULT_VALUE} > "${BRIGHTNESS_FILE}"
if [ ! -f ${BRIGHTNESS_FILE} ]; then
echo ${BRIGHTNESS_DEFAULT_VALUE} > ${BRIGHTNESS_FILE}
fi
# Sanity check: Check if integer
brightness=$(cat "${BRIGHTNESS_FILE}")
if ! [ "${brightness}" -ne "${brightness}" ] 2> /dev/null; then
#echo "error: \"${brightness}\" is not a number" >&2
echo ${BRIGHTNESS_DEFAULT_VALUE} > "${BRIGHTNESS_FILE}"
brightness=$(cat ${BRIGHTNESS_FILE})
if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then
echo ${BRIGHTNESS_DEFAULT_VALUE} > ${BRIGHTNESS_FILE}
brightness=${BRIGHTNESS_DEFAULT_VALUE}
fi
echo ${brightness}

View File

@ -1,7 +1,13 @@
#!/bin/sh
SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness"
SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness
let brightness=$(cat "${SYSTEM_BRIGHTNESS}")*10-10
# Check args
if [ ${#} -ne 0 ]; then
echo "Usage: $(basename ${0})"
exit 1
fi
let brightness=$(cat ${SYSTEM_BRIGHTNESS})*10-10
echo ${brightness}
exit 0

View File

@ -1,11 +1,11 @@
#!/bin/sh
BRIGHTNESS_FILE="/etc/current_brightness"
SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness"
BRIGHTNESS_FILE=/etc/current_brightness
SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness
# Check args
if [ ${#} != 1 ]; then
echo "Usage: ${0} new_brightness_percentage"
if [ ${#} -ne 1 ]; then
echo "Usage: $(basename ${0}) new_brightness_percentage"
exit 1
fi
@ -19,10 +19,10 @@ brightness_percentage=${1}
# Set new brightness percentage
let value=${1}+10
let value/=10
echo ${value} > "${SYSTEM_BRIGHTNESS}"
echo ${value} > ${SYSTEM_BRIGHTNESS}
# Set new brightness value in brightness file
if [ ${?} -eq 0 ]; then
echo ${brightness_percentage} > "${BRIGHTNESS_FILE}"
echo ${brightness_percentage} > ${BRIGHTNESS_FILE}
fi
exit 0

View File

@ -1,11 +1,14 @@
#!/bin/sh
SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness"
SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness
if [ ${#} != 1 ]; then
echo "Usage: $0 new_brightness_percentage"
# Check args
if [ ${#} -ne 1 ]; then
echo "Usage: $(basename ${0}) new_brightness_percentage"
exit 1
fi
# Check value's range
if [ ${1} -gt 100 ]; then
echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100"
exit 1
@ -14,5 +17,5 @@ fi
# Set new brightness percentage
let value=${1}+10
let value/=10
echo ${value} > "${SYSTEM_BRIGHTNESS}"
echo ${value} > ${SYSTEM_BRIGHTNESS}
exit 0

View File

@ -1,3 +1,4 @@
#!/bin/sh
killall mednafen gpsp psnes pcsx sdlgnuboy PicoDriveBin
exit 0

View File

@ -13,14 +13,14 @@ LOW_BAT_SECS_DISPLAYED=5
LOW_BAT_SECS_NOT_DISPLAYED=5
# Files and commands declaration
USB_PRESENT_FILE="/sys/class/power_supply/axp20x-usb/present"
#USB_PRESENT_FILE="/sys/class/power_supply/axp20x-ac/present" # Cheat for no USB present simulation when debugging
BAT_PRESENT_FILE="/sys/class/power_supply/axp20x-battery/present"
BAT_PERCENT_FILE="/sys/class/power_supply/axp20x-battery/capacity"
BAT_PERCENT_RESCALED_FILE="/etc/current_battery_percentage"
LOW_BAT_ICON="/sys/class/graphics/fb0/low_battery"
SCHEDULE_SHUTDOWN_CMD="sched_shutdown"
SIGNAL_URS1_TO_EMULATORS_CMD="signal_usr1_to_emulators"
USB_PRESENT_FILE=/sys/class/power_supply/axp20x-usb/present
#USB_PRESENT_FILE=/sys/class/power_supply/axp20x-ac/present # Cheat for no USB present simulation when debugging
BAT_PRESENT_FILE=/sys/class/power_supply/axp20x-battery/present
BAT_PERCENT_FILE=/sys/class/power_supply/axp20x-battery/capacity
BAT_PERCENT_RESCALED_FILE=/etc/current_battery_percentage
LOW_BAT_ICON=/sys/class/graphics/fb0/low_battery
SCHEDULE_SHUTDOWN_CMD=sched_shutdown
SIGNAL_URS1_TO_EMULATORS_CMD=signal_usr1_to_emulators
# Variables declaration
low_bat_status=0
@ -38,7 +38,7 @@ while true; do
#echo "Bat percentage: "$(cat ${BAT_PERCENT_FILE})"
# Get current bat percentage here once
cur_bat_percent=$(cat "${BAT_PERCENT_FILE}")
cur_bat_percent=$(cat ${BAT_PERCENT_FILE})
#echo "cur_bat_percent = ${cur_bat_percent}"
# Rescale bat percentage between 0 and RESCALE_MAX_PERCENTAGE
@ -50,7 +50,7 @@ while true; do
#echo "bat_percent_rescaled_maxed = ${bat_percent_rescaled_maxed}"
# Save in file
echo ${bat_percent_rescaled_maxed} > "${BAT_PERCENT_RESCALED_FILE}"
echo ${bat_percent_rescaled_maxed} > ${BAT_PERCENT_RESCALED_FILE}
# Low bat status detection
if [ "$(cat ${USB_PRESENT_FILE})" -eq "0" ]; then
@ -59,42 +59,42 @@ while true; do
if [ "${cur_bat_percent}" -ne "0" ]; then
# Check if we must change state
if [ "{$cur_bat_percent}" -le "${THRESHOLD_PERCENT_LOW_BAT}" -a "${low_bat_status}" -eq "0" ]; then
if [ {$cur_bat_percent} -le ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 0 ]; then
# Set Low Bat status
low_bat_status=1
low_bat_displayed=1
cur_secs_disp=0
echo 1 > "${LOW_BAT_ICON}"
echo 1 > ${LOW_BAT_ICON}
elif [ "${cur_bat_percent}" -gt "${THRESHOLD_PERCENT_LOW_BAT}" -a "${low_bat_status}" -eq "1" ]; then
elif [ ${cur_bat_percent} -gt ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 1 ]; then
# Reset status
low_bat_status=0
cur_nb_extremely_low_bat_before_shutdown=0
echo 0 > "${LOW_BAT_ICON}"
echo 0 > ${LOW_BAT_ICON}
fi
fi
else
if [ "${low_bat_status}" -eq "1" ]; then
if [ ${low_bat_status} -eq 1 ]; then
# Reset status
low_bat_status=0
cur_nb_extremely_low_bat_before_shutdown=0
echo 0 > "${LOW_BAT_ICON}"
echo 0 > ${LOW_BAT_ICON}
fi
fi
# Low bat processing
if [ "${low_bat_status}" -eq "1" ]; then
if [ ${low_bat_status} -eq 1 ]; then
# Check extremely low bat for clean shutdown
if [ "${cur_bat_percent}" -le "${THRESHOLD_PERCENT_EXTREMELY_LOW_BAT}" ]; then
if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_EXTREMELY_LOW_BAT} ]; then
let cur_nb_extremely_low_bat_before_shutdown++
echo "cur_nb_extremely_low_bat_before_shutdown = ${cur_nb_extremely_low_bat_before_shutdown}"
# Clean shutdown
if [ "${cur_nb_extremely_low_bat_before_shutdown}" -ge "${MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN}" ]; then
if [ ${cur_nb_extremely_low_bat_before_shutdown} -ge ${MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN} ]; then
echo "Battery extremely low, shutting down now..."
sched_shutdown 1 & signal_usr1_to_emulators
exit 0
@ -102,15 +102,15 @@ while true; do
fi
# Blinking process
if [ "${BLINK_ICON}" -eq "1" ]; then
if [ "${low_bat_displayed}" -eq "1" -a "${cur_secs_disp}" -ge "${LOW_BAT_SECS_DISPLAYED}" ]; then
if [ ${BLINK_ICON} -eq 1 ]; then
if [ ${low_bat_displayed} -eq 1 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_DISPLAYED} ]; then
low_bat_displayed=0
cur_secs_disp=0
echo 0 > "${LOW_BAT_ICON}"
elif [ "${low_bat_displayed}" -eq "0" -a "${cur_secs_disp}" -ge "${LOW_BAT_SECS_NOT_DISPLAYED}" ]; then
echo 0 > ${LOW_BAT_ICON}
elif [ ${low_bat_displayed} -eq 0 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_NOT_DISPLAYED} ]; then
low_bat_displayed=1
cur_secs_disp=0
echo 1 > "${LOW_BAT_ICON}"
echo 1 > ${LOW_BAT_ICON}
fi
fi
fi

View File

@ -1,7 +1,8 @@
#!/bin/sh
# Clear all current notifications
NOTIFICATION_DISPLAY="/sys/class/graphics/fb0/notification"
printf "clear" > "${NOTIFICATION_DISPLAY}"
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
printf "clear" > ${NOTIFICATION_DISPLAY}
exit 0

View File

@ -3,7 +3,7 @@
# Special char: ^ to add a new line
# Set seconds to 0 to display indefinitely (until the next notif)
NOTIFICATION_DISPLAY="/sys/class/graphics/fb0/notification"
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
display_usage() {
echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n"
@ -18,21 +18,21 @@ fi
# Get number of seconds to display notif
nb_secs=${1}
if ! [ "${nb_secs}" -ne "${nb_secs}" ] 2> /dev/null; then
echo "error: \"${nb_secs}\" is not a number" >&2
if ! [ ! "${nb_secs}" -ne "${nb_secs}" ] 2> /dev/null; then
echo "error: ${nb_secs} is not a number" >&2
exit 1
fi
# Print notif
printf "${*:2}" > "${NOTIFICATION_DISPLAY}"
printf "${*:2}" > ${NOTIFICATION_DISPLAY}
# Clear notif if NB_SECS is not 0, otherwise never clear
if [ "${nb_secs}" -ne "0" ]; then
if [ ${nb_secs} -ne 0 ]; then
# Wait time before clearing notif
sleep ${nb_secs}
# Clear notif
printf "clear" > "${NOTIFICATION_DISPLAY}"
printf "clear" > ${NOTIFICATION_DISPLAY}
fi
exit 0

View File

@ -3,14 +3,14 @@
# Special char: ^ to add a new line
# Set seconds to 0 to display indefinitely (until the next notif_set)
NOTIFICATION_DISPLAY="/sys/class/graphics/fb0/notification"
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
display_usage() {
echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n"
}
# If less than two arguments supplied, display usage
if [ $# -le 1 ]; then
if [ ${#} -le 1 ]; then
echo "Erase previous notif and display new one in background process for a certain amount of time"
echo "Special char: ^ to add a new line"
echo "Set seconds to 0 to display indefinitely (until the next $(basename ${0}))"
@ -20,8 +20,8 @@ fi
# Get number of seconds to display notif
nb_secs=${1}
if ! [ "${nb_secs}" -ne "${nb_secs}" ]; then
echo "error: \"${nb_secs}\" is not a number" >&2
if ! [ ! "${nb_secs}" -ne "${nb_secs}" ]; then
echo "error: ${nb_secs} is not a number" >&2
exit 1
fi
@ -29,7 +29,7 @@ fi
pkill notif_disp 2> /dev/null
## Clear previous notif
#printf "clear" > "${NOTIFICATION_DISPLAY}"
#printf "clear" > ${NOTIFICATION_DISPLAY}
# Print new notif
notif_disp "$@" &

View File

@ -8,12 +8,12 @@ current_brightness=$(brightness_get)
# Compute new brightness value
new_brightness=0
if [ "${current_brightness}" -gt "${STEP_BRIGHTNESS}" ]; then
if [ ${current_brightness} -gt ${STEP_BRIGHTNESS} ]; then
let new_brightness=${current_brightness}-${STEP_BRIGHTNESS}
fi
# Change brightness
if [ "${new_brightness}" -ne "${current_brightness}" ]; then
if [ ${new_brightness} -ne ${current_brightness} ]; then
brightness_set ${new_brightness}
fi

View File

@ -8,12 +8,12 @@ current_brightness=$(brightness_get)
# Compute new brightness value
new_brightness=${current_brightness}+${STEP_BRIGHTNESS}
if [ "${new_brightness}" -gt "100" ]; then
if [ ${new_brightness} -gt 100 ]; then
new_brightness=100
fi
# Change brightness
if [ "${new_brightness}" -ne "${current_brightness}" ]; then
if [ ${new_brightness} -ne ${current_brightness} ]; then
brightness_set ${new_brightness}
fi

View File

@ -8,12 +8,12 @@ current_volume=$(volume_get)
# Compute new volume value
new_volume=0
if [ "${current_volume}" -gt "${STEP_VOLUME}" ]; then
if [ ${current_volume} -gt ${STEP_VOLUME} ]; then
new_volume=${current_volume}-${STEP_VOLUME}
fi
# Change volume
if [ "${new_volume}" -ne "${current_volume}" ]; then
if [ ${new_volume} -ne ${current_volume} ]; then
volume_set ${new_volume}
fi

View File

@ -8,12 +8,12 @@ current_volume=$(volume_get)
# Compute new volume value
new_volume=${current_volume}+${STEP_VOLUME}
if [ "{new_$volume}" -gt "100" ]; then
if [ ${new_volume} -gt 100 ]; then
new_volume=100
fi
# Change volume
if [ "${new_volume}" -ne "{current_$volume}" ]; then
if [ ${new_volume} -ne {current_$volume} ]; then
volume_set ${new_volume}
fi

View File

@ -1,6 +1,6 @@
#!/bin/sh
if [ "${#}" != "1" ]; then
if [ ${#} != 1 ]; then
echo "Usage: $0 seconds_before_shutdown"
exit 1
fi

View File

@ -48,7 +48,7 @@ mount_share () {
fi
# Create the directory structure if required
(cd /mnt; mkdir -p atari_lynx gb gba megadrive neo_geo_pocket nes ps1 snes wonderswan)
(cd /mnt; mkdir -p "Atari lynx" "Game Boy" "Game Boy Advance" "Game Gear" "Neo Geo Pocket" "NES" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan")
return 0
}

View File

@ -1,19 +1,19 @@
#!/bin/sh
# Check number of args
if [ "${#}" -ne "1" ]; then
echo "Usage: $0 [1 for on, 0 for off]"
if [ ${#} -ne 1 ]; then
echo "Usage: $(basename ${0}) [1 for on, 0 for off]"
exit 1
fi
# Check Enable arg
enable=$1
if [ "${enable}" -eq "1" ]; then
echo "Turning ampli ON"
elif [ "${enable}" -eq "0" ]; then
echo "Turning ampli OFF"
enable=${1}
if [ ${enable} -eq 1 ]; then
echo "Turning audio amplifier ON"
elif [ ${enable} -eq 0 ]; then
echo "Turning audio amplifier OFF"
else
echo "Usage: ${0} [1 for on, 0 for off]"
echo "Usage: $(basename ${0}) [1 for on, 0 for off]"
exit 1
fi
@ -21,11 +21,11 @@ fi
GPIO_PF6=166
# Export GPIO
if [ ! -d "/sys/class/gpio/gpio${GPIO_PF6}" ]; then
echo ${GPIO_PF6} > "/sys/class/gpio/export"
if [ ! -d /sys/class/gpio/gpio${GPIO_PF6} ]; then
echo ${GPIO_PF6} > /sys/class/gpio/export
fi
# Enable/disable cmd
echo "out" > "/sys/class/gpio/gpio${GPIO_PF6}/direction"
echo ${enable} > "/sys/class/gpio/gpio${GPIO_PF6}/value"
echo "out" > /sys/class/gpio/gpio${GPIO_PF6}/direction
echo ${enable} > /sys/class/gpio/gpio${GPIO_PF6}/value
exit 0

View File

@ -1,12 +1,12 @@
#!/bin/sh
LOCK_FILE="/var/lock/gpio_manager.lock"
LOCK_FILE=/var/lock/gpio_manager.lock
if [ -f "${LOCK_FILE}" ]; then
if [ -f ${LOCK_FILE} ]; then
echo "${LOCK_FILE} already exists"
exit 1
fi
touch "${LOCK_FILE}"
touch ${LOCK_FILE}
funkey_gpio_management
rm "${LOCK_FILE}"
exit 0

View File

@ -1,22 +1,22 @@
#!/bin/sh
LOCK_FILE="/var/lock/launcher.lock"
PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher"
PREVENT_LAUNCHER_FILE2="/boot/prevent_launcher"
LOCK_FILE=/var/lock/launcher.lock
PREVENT_LAUNCHER_FILE=/mnt/prevent_launcher
PREVENT_LAUNCHER_FILE2=/boot/prevent_launcher
QUICK_LOAD_FILE=/root/quick_load_cmd
if [ -f "${LOCK_FILE}" ]; then
if [ -f ${LOCK_FILE} ]; then
echo "${LOCK_FILE} already exists"
exit 1
fi
touch "${LOCK_FILE}"
touch ${LOCK_FILE}
# Launch Previous Game
QUICK_LOAD_FILE="/root/quick_load_cmd"
if [ -f "${QUICK_LOAD_FILE}" ]; then
command=$(cat "${QUICK_LOAD_FILE}")
if [ -f ${QUICK_LOAD_FILE} ]; then
command=$(cat ${QUICK_LOAD_FILE})
echo "Found quick load file, restarting previous game with command:"
echo ${command}
rm "${QUICK_LOAD_FILE}"
rm ${QUICK_LOAD_FILE}
eval ${command}
termfix_all
fi
@ -25,10 +25,10 @@ fi
while true; do
# Check if prevent launcher file present
if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then
if [ -f ${PREVENT_LAUNCHER_FILE} ]; then
echo "Found file: ${PREVENT_LAUNCHER_FILE}, not launching launcher"
sleep 5
elif [ -f "${PREVENT_LAUNCHER_FILE2}" ]; then
elif [ -f ${PREVENT_LAUNCHER_FILE2} ]; then
echo "Found file: ${PREVENT_LAUNCHER_FILE2}, not launching launcher"
sleep 5
else
@ -39,5 +39,5 @@ while true; do
termfix_all
fi
done
rm "${LOCK_FILE}"
rm ${LOCK_FILE}
exit 0

View File

@ -1,6 +1,7 @@
#!/bin/sh
UPDATE_PERIOD=2 #seconds
notif_dirty=0
perform=0
@ -8,7 +9,7 @@ perform=0
function toggle_perform()
{
let perform=1-${perform}
if [ "${perform}" -eq "0" ]; then
if [ ${perform} -eq 0 ]; then
notif_clear
notif_dirty=1
fi
@ -16,7 +17,7 @@ function toggle_perform()
trap toggle_perform SIGUSR1
while true; do
if [ "${perform}" -eq "1" ]; then
if [ ${perform} -eq 1 ]; then
# Compute stats
cpu=$(printf "%.1f\n" $(mpstat -P ALL $UPDATE_PERIOD 1 | tail -1 | awk '{print 100-$12}'))
@ -24,7 +25,7 @@ while true; do
ram_swap=$(printf "%.1f\n" $(free | grep Swap | awk '{print $3/$2 * 100.0}'))
# Notif
if [ "${notif_dirty}" == "1" ]]; then
if [ ${notif_dirty} == 1 ]]; then
notif_clear
notif_dirty=0
else

View File

@ -1,6 +1,6 @@
#!/bin/sh
for i in $(seq 0 11); do
termfix /dev/tty$i
termfix /dev/tty${i}
done
exit 0

View File

@ -1,19 +1,23 @@
#!/bin/sh
VOLUME_FILE="/etc/current_volume"
VOLUME_FILE=/etc/current_volume
VOLUME_DEFAULT_VALUE=50
# Check args
if [ ${#} -ne 0 ]; then
echo "Usage: $(basename ${0})"
exit 1
fi
# Sanity check: File does not exist
if [ ! -f "${VOLUME_FILE}" ]; then
#echo "error: \"${VOLUME_FILE}\" does not exist" >&2
echo ${VOLUME_DEFAULT_VALUE} > "${VOLUME_FILE}"
if [ ! -f ${VOLUME_FILE} ]; then
echo ${VOLUME_DEFAULT_VALUE} > ${VOLUME_FILE}
fi
# Sanity check: Check if integer
volume=$(cat "${VOLUME_FILE}")
if ! [ "${volume}" -ne "${volume}" ] ; then
#echo "error: \"${volume}\" is not a number" >&2
echo ${VOLUME_DEFAULT_VALUE} > "${VOLUME_FILE}"
if ! [ ! "${volume}" -ne "${volume}" ] 2> /dev/null; then
echo ${VOLUME_DEFAULT_VALUE} > ${VOLUME_FILE}
volume=${VOLUME_DEFAULT_VALUE}
fi
echo ${volume}

View File

@ -1,10 +1,10 @@
#!/bin/sh
VOLUME_FILE="/etc/current_volume"
VOLUME_FILE=/etc/current_volume
# Check args
if [ ${#} != 1 ]; then
echo "Usage: ${0} new_volume_percentage"
if [ ${#} -ne 1 ]; then
echo "Usage: $(basename ${0}) new_volume_percentage"
exit 1
fi
@ -16,22 +16,15 @@ fi
# Scale new volume value between 0 and 63
volume_percent=${1}
volume_integer=$(echo ${volume_percent} 63 100 | awk '{printf int($1*$2/$3)}')
volume_decimal=$(echo ${volume_percent} 63 100 ${volume_integer} | awk '{printf (($1*$2/$3)-$4)*100}')
if [ "${volume_decimal}" -ge "63" ]; then
let volume_integer++
fi
volume_scaled=${volume_integer}
volume_scaled=$(echo "a = ${1} * 63 / 100 + 0.5; scale = 0; a / 1" | bc -l)
# Get current value
current_volume=$(volume_get)
# Turn on/off ampli if necessary
if [ "${current_volume}" -eq "0" -a "${volume_scaled}" -ne "0" ]; then
echo "Turning AMP on"
# Turn on/off audio amplifier if necessary
if [ ${current_volume} -eq 0 -a ${volume_scaled} -ne 0 ]; then
start_audio_amp 1
elif [ "${current_volume}" -ne "0" -a "${volume_scaled}" -eq "0" ]; then
echo "Turning AMP off"
elif [ ${current_volume} -ne 0 -a ${volume_scaled} -eq 0 ]; then
start_audio_amp 0
fi
@ -40,6 +33,6 @@ amixer -q sset 'Headphone' ${volume_scaled} unmute
# Change new volume value in volume file
if [ ${?} -eq 0 ]; then
echo ${volume_percent} > "${VOLUME_FILE}"
echo ${volume_percent} > ${VOLUME_FILE}
fi
exit 0

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Check args
if [ ${#} != 1 ]; then
if [ ${#} -ne 1 ]; then
echo "Usage: ${0} new_volume_percentage"
exit 1
fi
@ -14,22 +14,15 @@ fi
# Scale new volume value between 0 and 63
volume_percent=${1}
volume_integer=$(echo ${volume_percent} 63 100 | awk '{printf int($1*$2/$3)}')
volume_deccimal=$(echo ${volume_percent} 63 100 ${volume_integer} | awk '{printf (($1*$2/$3)-$4)*100}')
if [ "{$volume_decimal}" -ge "63" ]; then
let volume_integer++
fi
volume_scaled=${volume_integer}
volume_scaled=$(echo "a = ${1} * 63 / 100 + 0.5; scale = 0; a / 1" | bc -l)
# Get current value
current_volume=$(volume_get)
# Turn on/off ampli if necessary
if [ "${current_volume}" -eq "0" -a "${volume_scaled}" -ne "0" ]; then
echo "Turning AMP on"
if [ ${current_volume} -eq 0 -a ${volume_scaled} -ne 0 ]; then
start_audio_amp 1
elif [ "${current_volume}" -ne "0" -a "${volume_scaled}" -eq "0" ]; then
echo "Turning AMP off"
elif [ ${current_volume} -ne 0 -a ${volume_scaled} -eq 0 ]; then
start_audio_amp 0
fi

View File

@ -1,7 +1,7 @@
#!/bin/sh
# Write quick load file args
QUICK_LOAD_FILE="/root/quick_load_cmd"
QUICK_LOAD_FILE=/root/quick_load_cmd
printf "" > $QUICK_LOAD_FILE