change for new notif script

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK 2021-05-15 23:02:06 +02:00
parent 547c1fe5b9
commit 8c3bdba798
33 changed files with 354 additions and 254 deletions

View File

@ -22,16 +22,7 @@ if [ $? -ne 0 ]; then
local return_code=$1 local return_code=$1
shift shift
warn "$@" warn "$@"
notif "$@" notif set 0 "$@"
exit $return_code exit $return_code
} }
fi fi
notif () {
info "$@"
printf "$@" > /sys/class/graphics/fb0/notification
}
clear_notif () {
printf "clear" > /sys/class/graphics/fb0/notification
}

View File

@ -78,7 +78,7 @@ function launch_tests_up_until_magnet {
termfix_all > /dev/null termfix_all > /dev/null
## Clear all notifs ## Clear all notifs
notif_clear notif clear
## Test if log file aleady exists ## Test if log file aleady exists
if [[ -f $LOG_FILE ]]; then if [[ -f $LOG_FILE ]]; then
@ -158,7 +158,7 @@ function launch_tests_up_until_magnet {
## Play 1kHz sine wave ## Play 1kHz sine wave
echo " Play 2kHz sine wave" echo " Play 2kHz sine wave"
notif_set 0 "^^^ PLAYING SINE WAVE...^^^ ...... ^ ... ...^ .. ..^.. .^. . .^ . ..^ .. ..^ ... ...^ .......^^" notif set 0 "^^^ PLAYING SINE WAVE...^^^ ...... ^ ... ...^ .. ..^.. .^. . .^ . ..^ .. ..^ ... ...^ .......^^"
speaker-test -t sine -s 1 -f 2000 >/dev/null 2>&1 speaker-test -t sine -s 1 -f 2000 >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo " ERROR: SPEAKER SINE" echo " ERROR: SPEAKER SINE"
@ -166,7 +166,7 @@ function launch_tests_up_until_magnet {
return return
fi fi
sync sync
notif_clear notif clear
## Launch prod screen test speaker ## Launch prod screen test speaker
$PROD_SCREEN_BIN SPEAKER 2>&1 $PROD_SCREEN_BIN SPEAKER 2>&1
@ -248,7 +248,7 @@ function launch_tests_after_magnet {
#termfix_all > /dev/null #termfix_all > /dev/null
## Clear all notifs ## Clear all notifs
#notif_clear #notif clear
# Log from magnet file # Log from magnet file
echo " Found file: " $MAGNET_DETECTED_FILE echo " Found file: " $MAGNET_DETECTED_FILE

View File

@ -33,7 +33,7 @@ increase_brightness() {
fi fi
# Notif # Notif
notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%"
} }
decrease_brightness() { decrease_brightness() {
@ -53,7 +53,7 @@ decrease_brightness() {
fi fi
# Notif # Notif
notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%"
} }
get_brightness() { get_brightness() {

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
notif_set 0 " Getting system stats..." notif set 0 " Getting system stats..."
killall -s USR1 system_stats killall -s USR1 system_stats
exit 0 exit 0

View File

@ -216,29 +216,29 @@ copy_files_to_usb_partition () {
} }
check_root_id check_root_id
notif " FIRST BOOT DETECTED" notif set 0 " FIRST BOOT DETECTED"
notif " 1/6 RESIZE ROOT PARTITION" notif set 0 " 1/6 RESIZE ROOT PARTITION"
resize_rootfs_partition resize_rootfs_partition
notif " 2/6 RESIZE ROOT FILESYSTEM" notif set 0 " 2/6 RESIZE ROOT FILESYSTEM"
resize_rootfs_filesystem resize_rootfs_filesystem
notif " 3/6 CREATE SWAP" notif set 0 " 3/6 CREATE SWAP"
create_swap create_swap
notif " 4/6 CREATE USB PARTITION" notif set 0 " 4/6 CREATE USB PARTITION"
create_usb_partition create_usb_partition
notif " 5/6 FORMAT USB PARTITION" notif set 0 " 5/6 FORMAT USB PARTITION"
format_usb_partition format_usb_partition
notif " 6/6 COPY FILES TO ^ USB PARTITION" notif set 0 " 6/6 COPY FILES TO ^ USB PARTITION"
copy_files_to_usb_partition copy_files_to_usb_partition
notif " FIRST BOOT SETUP FINISHED!" notif set 0 " FIRST BOOT SETUP FINISHED!"
fw_setenv first_boot_ok 1 fw_setenv first_boot_ok 1
sleep 1 sleep 1
clear_notif notif clear

View File

@ -0,0 +1,78 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
SELF="$(basename ${0})"
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
usage() {
>&2 echo "Usage: ${SELF} set duration message"
>&2 echo " ${SELF} display duration message"
>&2 echo " ${SELF} clear"
exit 1
}
notif_clear() {
printf "clear" > "${NOTIFICATION_DISPLAY}"
}
notif_display() {
local duration="${1}"
local message="${*:2}"
if ! [ ! "${duration}" -ne "${duration}" ] 2> /dev/null; then
>&2 echo "error: ${duration} is not a number"
exit 3
fi
printf "${message}" > "${NOTIFICATION_DISPLAY}"
if [ ${duration} -ne 0 ]; then
sleep ${duration}
notif_clear
fi
}
notif_set() {
local duration="${1}"
local message="${*:2}"
if ! [ ! "${duration}" -ne "${duration}" ]; then
>&2 echo "error: ${duration} is not a number"
exit 2
fi
# Kill previous notif disp process
pkill -f "notif display" 2> /dev/null
# Print new notif
notif display "${duration}" "${message}" &
}
case "${1}" in
set)
if [ ${#} -ne 3 ]; then
usage
fi
shift
notif_set "${1}" "${2}"
;;
clear)
if [ ${#} -ne 1 ]; then
usage
fi
notif_clear
;;
display)
if [ ${#} -ne 3 ]; then
usage
fi
shift
notif_display "${1}" "${2}"
;;
*)
usage
;;
esac
exit 0

View File

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

View File

@ -1,38 +0,0 @@
#!/bin/sh
# Display notification for a certain amount of time
# 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
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
echo "Display notification for a certain amount of time"
display_usage
exit 1
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
exit 1
fi
# Print notif
printf "${*:2}" > ${NOTIFICATION_DISPLAY}
# Clear notif if NB_SECS is not 0, otherwise never clear
if [ ${nb_secs} -ne 0 ]; then
# Wait time before clearing notif
sleep ${nb_secs}
# Clear notif
printf "clear" > ${NOTIFICATION_DISPLAY}
fi
exit 0

View File

@ -1,36 +0,0 @@
#!/bin/sh
# Erase previous notif and display new one in background process for a certain amount of seconds
# 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
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
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}))"
display_usage
exit 1
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
exit 1
fi
# Kill previous notif_disp process
pkill notif_disp 2> /dev/null
## Clear previous notif
#printf "clear" > ${NOTIFICATION_DISPLAY}
# Print new notif
notif_disp "$@" &
exit 0

View File

@ -54,7 +54,7 @@ mount_share () {
# Check if there is a firmware update file # Check if there is a firmware update file
if [ -f /mnt/FunKey-*.fwu ]; then if [ -f /mnt/FunKey-*.fwu ]; then
warn "found a firmware update file, going into recovery mode" warn "found a firmware update file, going into recovery mode"
notif "^^^^^^^^ UPDATING...^^^^^^^^" notif set 0 "^^^^^^^^ UPDATING...^^^^^^^^"
recovery_mode recovery_mode
fi fi

View File

@ -4,7 +4,7 @@
sync sync
# Notif fullscreen "Shutting down" # Notif fullscreen "Shutting down"
notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" notif set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^"
# Notify system, reboot in progress # Notify system, reboot in progress
REBOOTING_FILE="/run/rebooting" REBOOTING_FILE="/run/rebooting"

View File

@ -24,7 +24,7 @@ mkdir -p "${SNAPSHOT_DIR}"
last=$(cd ${SNAPSHOT_DIR}; ls IMG_*.${SNAPSHOT_EXT} 2> /dev/null | tail -1 | sed 's/^IMG_0*\([0-9]\+\)\.'${SNAPSHOT_EXT}'$/\1/') last=$(cd ${SNAPSHOT_DIR}; ls IMG_*.${SNAPSHOT_EXT} 2> /dev/null | tail -1 | sed 's/^IMG_0*\([0-9]\+\)\.'${SNAPSHOT_EXT}'$/\1/')
let last=${last}+1 let last=${last}+1
snapshot_file=$(printf "IMG_%04d.${SNAPSHOT_EXT}" $last) snapshot_file=$(printf "IMG_%04d.${SNAPSHOT_EXT}" $last)
notif_set 2 " SCREENSHOT ${snapshot_file}" notif set 2 " SCREENSHOT ${snapshot_file}"
fbgrab "${SNAPSHOT_DIR}/${snapshot_file}" >/dev/null 2>&1 & fbgrab "${SNAPSHOT_DIR}/${snapshot_file}" >/dev/null 2>&1 &
# Remove lock file # Remove lock file

View File

@ -10,7 +10,7 @@ function toggle_perform()
{ {
let perform=1-${perform} let perform=1-${perform}
if [ ${perform} -eq 0 ]; then if [ ${perform} -eq 0 ]; then
notif_clear notif clear
notif_dirty=1 notif_dirty=1
fi fi
} }
@ -27,13 +27,13 @@ while true; do
# Notif # Notif
if [ ${notif_dirty} -eq 1 ]; then if [ ${notif_dirty} -eq 1 ]; then
notif_clear notif clear
notif_dirty=0 notif_dirty=0
else else
if [ "x${ip_addr}" != "x" ]; then if [ "x${ip_addr}" != "x" ]; then
notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}"
else else
notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%"
fi fi
fi fi
else else

View File

@ -33,7 +33,7 @@ increase_volume() {
fi fi
# Notif # Notif
notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" notif set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%"
} }
decrease_volume() { decrease_volume() {
@ -53,7 +53,7 @@ decrease_volume() {
fi fi
# Notif # Notif
notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" notif set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%"
} }
get_volume() { get_volume() {

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
FCEUX_VERSION = f089cec FCEUX_VERSION = c3ae7fa
FCEUX_SITE_METHOD = git FCEUX_SITE_METHOD = git
FCEUX_SITE = https://github.com/FunKey-Project/fceux.git FCEUX_SITE = https://github.com/FunKey-Project/fceux.git
FCEUX_LICENSE = GPL-2.0 FCEUX_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
PCSX_REARMED_VERSION = a2f9326 PCSX_REARMED_VERSION = 2cc6248
PCSX_REARMED_SITE_METHOD = git PCSX_REARMED_SITE_METHOD = git
PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git
PCSX_REARMED_LICENSE = GPL-2.0 PCSX_REARMED_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
POCKETSNES_VERSION = 5eb2635 POCKETSNES_VERSION = c3de812
POCKETSNES_SITE_METHOD = git POCKETSNES_SITE_METHOD = git
POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git
POCKETSNES_LICENSE = GPL-2.0 POCKETSNES_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
GNUBOY_VERSION = a0d8d26 GNUBOY_VERSION = f6b8feb
GNUBOY_SITE_METHOD = git GNUBOY_SITE_METHOD = git
GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git
GNUBOY_LICENSE = GPL-2.0 GNUBOY_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
GPSP_VERSION = b573bc6 GPSP_VERSION = 5ab34a8
GPSP_SITE_METHOD = git GPSP_SITE_METHOD = git
GPSP_SITE = https://github.com/FunKey-Project/gpsp.git GPSP_SITE = https://github.com/FunKey-Project/gpsp.git
GPSP_LICENSE = GPL-2.0 GPSP_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
MEDNAFEN_VERSION = d535dff MEDNAFEN_VERSION = 2d9ca9d
MEDNAFEN_SITE_METHOD = git MEDNAFEN_SITE_METHOD = git
MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git
MEDNAFEN_LICENSE = GPL-2.0+ MEDNAFEN_LICENSE = GPL-2.0+

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
PICODRIVE_VERSION = 59b9892 PICODRIVE_VERSION = 4c09c0b
PICODRIVE_SITE_METHOD = git PICODRIVE_SITE_METHOD = git
PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git
PICODRIVE_LICENSE = MAME PICODRIVE_LICENSE = MAME

View File

@ -10,7 +10,7 @@ case "$1" in
if [ "${keys}" != "0xF83F" ]; then if [ "${keys}" != "0xF83F" ]; then
# Automatic firmware update requested # Automatic firmware update requested
updates=$(ls /mnt/FunKey-*.fwu) updates=$(ls /mnt/FunKey-*.fwu 2>/dev/null)
if [ "x${updates}" = "x" ]; then if [ "x${updates}" = "x" ]; then
menu & menu &
exit 1 exit 1
@ -18,11 +18,11 @@ case "$1" in
for file in ${updates} ; do for file in ${updates} ; do
swupdate -i "${file}" swupdate -i "${file}"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif_disp 10 " CORRUPTED^ UPDATE FILE" notif display 10 " CORRUPTED^ UPDATE FILE"
rm -f "${file}" rm -f "${file}"
fi fi
done done
notif "^^^^^^^^ RESTARTING...^^^^^^^^" notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^"
normal_mode normal_mode
else else

View File

@ -18,12 +18,3 @@ if [ $? -ne 0 ]; then
exit $return_code exit $return_code
} }
fi fi
notif () {
info "$@"
printf "$@" > /sys/class/graphics/fb0/notification
}
clear_notif () {
printf "clear" > /sys/class/graphics/fb0/notification
}

View File

@ -0,0 +1,128 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
SELF="$(basename ${0})"
SYSTEM_BRIGHTNESS="/sys/class/backlight/backlight/brightness"
DEFAULT_BRIGHTNESS_VALUE=100
BRIGHTNESS_STEP=10
NOTIF_DURATION=2
usage() {
>&2 echo "Usage: ${SELF} get"
>&2 echo " ${SELF} set new_brightness_percentage"
exit 1
}
increase_brightness() {
# Get current value
local current_brightness=$(get_brightness)
# Compute new brightness value
local new_brightness=0
let new_brightness=${current_brightness}+${BRIGHTNESS_STEP}
if [ ${new_brightness} -gt 100 ]; then
new_brightness=100
fi
# Change brightness
if [ ${new_brightness} -ne ${current_brightness} ]; then
set_brightness ${new_brightness}
fi
# Notif
notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%"
}
decrease_brightness() {
# Get current value
local current_brightness=$(get_brightness)
# Compute new brightness value
local new_brightness=0
if [ ${current_brightness} -gt ${BRIGHTNESS_STEP} ]; then
let new_brightness=${current_brightness}-${BRIGHTNESS_STEP}
fi
# Change brightness
if [ ${new_brightness} -ne ${current_brightness} ]; then
set_brightness ${new_brightness}
fi
# Notif
notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%"
}
get_brightness() {
local brightness=$(fw_printenv -n brightness 2>/dev/null)
if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then
brightness=${DEFAULT_BRIGHTNESS_VALUE}
fw_setenv brightness ${brightness}
fi
echo ${brightness}
}
set_brightness() {
# Set the new brightness percentage in the kernel driver
local brightness=${1}
local kernel_brightness
let kernel_brightness=${brightness}+10
let kernel_brightness/=10
echo ${kernel_brightness} > "${SYSTEM_BRIGHTNESS}"
# Set the new brightness value in a bootloader variable
if [ ${?} -eq 0 -a $(get_brightness) -ne ${brightness} ]; then
fw_setenv brightness ${brightness}
fi
}
# Check number of arguments
if [ ${#} -lt 1 -o ${#} -gt 2 ]; then
usage
fi
case "${1}" in
up)
if [ ${#} -ne 1 ]; then
usage
fi
increase_brightness
;;
down)
if [ ${#} -ne 1 ]; then
usage
fi
decrease_brightness
;;
get)
if [ ${#} -ne 1 ]; then
usage
fi
get_brightness
;;
set)
if [ ${#} -ne 2 ]; then
usage
fi
# Make sure the argument is a positive number <= 100
if [ -n "${2}" ] && [ "${2}" -eq "${2}" ] 2>/dev/null && \
[ "${2}" -ge 0 ] && [ "${2}" -le 100 ]; then
set_brightness "${2}"
else
usage
fi
;;
*)
usage
;;
esac
exit 0

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
notif_set 0 "Getting system stats..." notif set 0 "Getting system stats..."
killall -s USR1 system_stats killall -s USR1 system_stats
exit 0 exit 0

View File

@ -11,8 +11,6 @@ getkey() {
# Display meny item # Display meny item
menu_display () { menu_display () {
local entry=${1} local entry=${1}
#clear_notif
case ${entry} in case ${entry} in
0) 0)
@ -92,7 +90,7 @@ menu_display () {
message=" SHUTDOWN" message=" SHUTDOWN"
;; ;;
esac esac
notif "${message}" notif set 0 "${message}"
} }
# Run menu item # Run menu item
@ -114,7 +112,7 @@ menu_run () {
umount ${rootfs_mount} umount ${rootfs_mount}
version_recovery=$(grep Recovery /etc/sw-versions | cut -f 2) version_recovery=$(grep Recovery /etc/sw-versions | cut -f 2)
ip_addr=$(ifconfig usb0 | grep "inet " | awk -F'[: ]+' '{ print $4 }') ip_addr=$(ifconfig usb0 | grep "inet " | awk -F'[: ]+' '{ print $4 }')
notif "${message}^^ Recovery: ${version_recovery}^ rootfs : ${version_rootfs}^ IP addr : ${ip_addr}" notif set 0 "${message}^^ Recovery: ${version_recovery}^ rootfs : ${version_rootfs}^ IP addr : ${ip_addr}"
;; ;;
1) 1)
@ -122,31 +120,31 @@ menu_run () {
# USB mount/unmount # USB mount/unmount
mount | grep -q /dev/mmcblk0p4 mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
notif "${message}..." notif set 0 "${message}..."
share start share start
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif "${message}...^CANNOT MOUNT USB!" notif set 0 "${message}...^CANNOT MOUNT USB!"
else else
message=" USB UNMOUNT" message=" USB UNMOUNT"
notif "${message}" notif set 0 "${message}"
fi fi
else else
notif "${message}..." notif set 0 "${message}..."
share stop share stop
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif "${message}...^CANNOT UNMOUNT USB!" notif set 0 "${message}...^CANNOT UNMOUNT USB!"
else else
for file in $(ls /mnt/FunKey-*.fwu); do for file in $(ls /mnt/FunKey-*.fwu); do
swupdate -i "${file}" swupdate -i "${file}"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif_disp 10 "${message}...^ CORRUPTED^ UPDATE FILE" notif set 0 display 10 "${message}...^ CORRUPTED^ UPDATE FILE"
rm -f "${file}" rm -f "${file}"
notif "^^^^^^^^ RESTARTING...^^^^^^^^" notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^"
normal_mode normal_mode
fi fi
done done
message=" USB MOUNT" message=" USB MOUNT"
notif "${message}" notif set 0 "${message}"
fi fi
fi fi
;; ;;
@ -156,23 +154,23 @@ menu_run () {
# USB check # USB check
mount | grep -q /dev/mmcblk0p4 mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
notif "${message}..." notif set 0 "${message}..."
umount /mnt >/dev/null 2>&1 umount /mnt >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif "${message}...^CANNOT CHECK USB!" notif set 0 "${message}...^CANNOT CHECK USB!"
fi fi
fsck.fat -a -v -w /dev/mmcblk0p4 fsck.fat -a -v -w /dev/mmcblk0p4
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif "${message}...^CANNOT CHECK USB!" notif set 0 "${message}...^CANNOT CHECK USB!"
fi fi
mount /mnt mount /mnt
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif "${message}...^CANNOT CHECK USB!" notif set 0 "${message}...^CANNOT CHECK USB!"
else else
notif "${message} DONE" notif set 0 "${message} DONE"
fi fi
else else
notif "${message}...^CANNOT CHECK USB WHEN MOUNTED!" notif set 0 "${message}...^CANNOT CHECK USB WHEN MOUNTED!"
fi fi
;; ;;
@ -181,7 +179,7 @@ menu_run () {
# USB format # USB format
mount | grep -q /dev/mmcblk0p4 mount | grep -q /dev/mmcblk0p4
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
notif "${message}...^PRESS A TO CONFIRM" notif set 0 "${message}...^PRESS A TO CONFIRM"
while true; do while true; do
case $(getkey) in case $(getkey) in
1e0001|1e0002) 1e0001|1e0002)
@ -189,9 +187,9 @@ menu_run () {
mkfs.vfat /dev/mmcblk0p4 && mkfs.vfat /dev/mmcblk0p4 &&
mount /mnt mount /mnt
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
notif "${message}...^CANNOT FORMAT USB!" notif set 0 "${message}...^CANNOT FORMAT USB!"
else else
notif "${message} DONE" notif set 0 "${message} DONE"
fi fi
break break
;; ;;
@ -200,13 +198,13 @@ menu_run () {
;; ;;
*) *)
notif "${message}...^ABORTED!" notif set 0 "${message}...^ABORTED!"
break break
;; ;;
esac esac
done done
else else
notif "${message}...^CANNOT FORMAT USB WHEN MOUNTED!" notif set 0 "${message}...^CANNOT FORMAT USB WHEN MOUNTED!"
fi fi
;; ;;
@ -222,9 +220,9 @@ menu_run () {
touch /mnt/usbnet touch /mnt/usbnet
message=" NETWORK: ENABLED" message=" NETWORK: ENABLED"
fi fi
notif "${message}" notif set 0 "${message}"
else else
notif "${message}...^CANNOT CHANGE NET IF MOUNTED!" notif set 0 "${message}...^CANNOT CHANGE NET IF MOUNTED!"
fi fi
;; ;;
@ -246,7 +244,7 @@ menu_run () {
fw_setenv assembly_tests 1 fw_setenv assembly_tests 1
message=" FACTORY TESTS: ENABLED" message=" FACTORY TESTS: ENABLED"
fi fi
notif "${message}" notif set 0 "${message}"
;; ;;
7) 7)
@ -260,16 +258,16 @@ menu_run () {
fw_setenv first_boot_ok 1 fw_setenv first_boot_ok 1
message=" FIRST BOOT: DISABLED" message=" FIRST BOOT: DISABLED"
fi fi
notif "${message}" notif set 0 "${message}"
;; ;;
8) 8)
notif "^^^^^^^^ RESTARTING...^^^^^^^^" notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^"
normal_mode normal_mode
;; ;;
9) 9)
notif "^^^^^^^^ SHUTDOWN...^^^^^^^^" notif set 0 "^^^^^^^^ SHUTDOWN...^^^^^^^^"
poweroff poweroff
;; ;;
esac esac

View File

@ -0,0 +1,78 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
SELF="$(basename ${0})"
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
usage() {
>&2 echo "Usage: ${SELF} set duration message"
>&2 echo " ${SELF} display duration message"
>&2 echo " ${SELF} clear"
exit 1
}
notif_clear() {
echo -n "clear" > "${NOTIFICATION_DISPLAY}"
}
notif_display() {
local duration="${1}"
local message="${*:2}"
if ! [ ! "${duration}" -ne "${duration}" ] 2> /dev/null; then
>&2 echo "error: ${duration} is not a number"
exit 3
fi
echo -n "${message}" > "${NOTIFICATION_DISPLAY}"
if [ ${duration} -ne 0 ]; then
sleep ${duration}
notif_clear
fi
}
notif_set() {
local duration="${1}"
local message="${*:2}"
if ! [ ! "${duration}" -ne "${duration}" ]; then
>&2 echo "error: ${duration} is not a number"
exit 2
fi
# Kill previous notif disp process
pkill -f "notif display" 2> /dev/null
# Print new notif
notif display "${duration}" "${message}" &
}
case "${1}" in
set)
if [ ${#} -ne 3 ]; then
usage
fi
shift
notif_set "${1}" "${2}"
;;
clear)
if [ ${#} -ne 1 ]; then
usage
fi
notif_clear
;;
display)
if [ ${#} -ne 3 ]; then
usage
fi
shift
notif_display "${1}" "${2}"
;;
*)
usage
;;
esac
exit 0

View File

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

View File

@ -1,38 +0,0 @@
#!/bin/sh
# Display notification for a certain amount of time
# 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
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
echo "Display notification for a certain amount of time"
display_usage
exit 1
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
exit 1
fi
# Print notif
printf "${*:2}" > ${NOTIFICATION_DISPLAY}
# Clear notif if NB_SECS is not 0, otherwise never clear
if [ ${nb_secs} -ne 0 ]; then
# Wait time before clearing notif
sleep ${nb_secs}
# Clear notif
printf "clear" > ${NOTIFICATION_DISPLAY}
fi
exit 0

View File

@ -1,36 +0,0 @@
#!/bin/sh
# Erase previous notif and display new one in background process for a certain amount of seconds
# 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
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
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}))"
display_usage
exit 1
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
exit 1
fi
# Kill previous notif_disp process
pkill notif_disp 2> /dev/null
## Clear previous notif
#printf "clear" > ${NOTIFICATION_DISPLAY}
# Print new notif
notif_disp "$@" &
exit 0

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# Notif fullscreen "Shutting down" # Notif fullscreen "Shutting down"
notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" notif set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^"
# Kill Emulators # Kill Emulators
#kill_emulators >/dev/null 2>&1 #kill_emulators >/dev/null 2>&1

View File

@ -24,7 +24,7 @@ mkdir -p "${SNAPSHOT_DIR}"
last=$(cd ${SNAPSHOT_DIR}; ls IMG_*.${SNAPSHOT_EXT} 2> /dev/null | tail -1 | sed 's/^IMG_0*\([0-9]\+\)\.'${SNAPSHOT_EXT}'$/\1/') last=$(cd ${SNAPSHOT_DIR}; ls IMG_*.${SNAPSHOT_EXT} 2> /dev/null | tail -1 | sed 's/^IMG_0*\([0-9]\+\)\.'${SNAPSHOT_EXT}'$/\1/')
let last=${last}+1 let last=${last}+1
snapshot_file=$(printf "IMG_%04d.${SNAPSHOT_EXT}" $last) snapshot_file=$(printf "IMG_%04d.${SNAPSHOT_EXT}" $last)
notif_set 2 " SCREENSHOT ${snapshot_file}" notif set 2 " SCREENSHOT ${snapshot_file}"
fbgrab "${SNAPSHOT_DIR}/${snapshot_file}" >/dev/null 2>&1 & fbgrab "${SNAPSHOT_DIR}/${snapshot_file}" >/dev/null 2>&1 &
# Remove lock file # Remove lock file

View File

@ -10,7 +10,7 @@ function toggle_perform()
{ {
let perform=1-${perform} let perform=1-${perform}
if [ ${perform} -eq 0 ]; then if [ ${perform} -eq 0 ]; then
notif_clear notif clear
notif_dirty=1 notif_dirty=1
fi fi
} }
@ -27,13 +27,13 @@ while true; do
# Notif # Notif
if [ ${notif_dirty} -eq 1 ]; then if [ ${notif_dirty} -eq 1 ]; then
notif_clear notif clear
notif_dirty=0 notif_dirty=0
else else
if [ "x${ip_addr}" != "x" ]; then if [ "x${ip_addr}" != "x" ]; then
notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}" notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%^IP:${ip_addr}"
else else
notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%"
fi fi
fi fi
else else