From 8c3bdba798eee1a9aad79d476cee5f569951b7aa Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sat, 15 May 2021 23:02:06 +0200 Subject: [PATCH] change for new notif script Signed-off-by: Michel-FK --- .../funkey/rootfs-overlay/usr/local/lib/utils | 11 +- .../usr/local/sbin/assembly_tests | 8 +- .../rootfs-overlay/usr/local/sbin/brightness | 4 +- .../usr/local/sbin/display_notif_system_stats | 2 +- .../rootfs-overlay/usr/local/sbin/first_boot | 18 +-- .../rootfs-overlay/usr/local/sbin/notif | 78 +++++++++++ .../rootfs-overlay/usr/local/sbin/notif_clear | 8 -- .../rootfs-overlay/usr/local/sbin/notif_disp | 38 ------ .../rootfs-overlay/usr/local/sbin/notif_set | 36 ----- .../rootfs-overlay/usr/local/sbin/share | 2 +- .../usr/local/sbin/shutdown_funkey | 2 +- .../rootfs-overlay/usr/local/sbin/snapshot | 2 +- .../usr/local/sbin/system_stats | 8 +- .../rootfs-overlay/usr/local/sbin/volume | 4 +- FunKey/package/FCEUX/FCEUX.mk | 2 +- FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk | 2 +- FunKey/package/PocketSNES/PocketSNES.mk | 2 +- FunKey/package/gnuboy/gnuboy.mk | 2 +- FunKey/package/gpsp/gpsp.mk | 2 +- FunKey/package/mednafen/mednafen.mk | 2 +- FunKey/package/picodrive/picodrive.mk | 2 +- .../rootfs-overlay/etc/init.d/S60recovery | 6 +- .../funkey/rootfs-overlay/usr/local/lib/utils | 9 -- .../rootfs-overlay/usr/local/sbin/brightness | 128 ++++++++++++++++++ .../usr/local/sbin/display_notif_system_stats | 2 +- .../funkey/rootfs-overlay/usr/local/sbin/menu | 56 ++++---- .../rootfs-overlay/usr/local/sbin/notif | 78 +++++++++++ .../rootfs-overlay/usr/local/sbin/notif_clear | 8 -- .../rootfs-overlay/usr/local/sbin/notif_disp | 38 ------ .../rootfs-overlay/usr/local/sbin/notif_set | 36 ----- .../usr/local/sbin/shutdown_funkey | 2 +- .../rootfs-overlay/usr/local/sbin/snapshot | 2 +- .../usr/local/sbin/system_stats | 8 +- 33 files changed, 354 insertions(+), 254 deletions(-) create mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp delete mode 100755 FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set create mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness create mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp delete mode 100755 Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils b/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils index ec02b68..0b554c3 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/lib/utils @@ -22,16 +22,7 @@ if [ $? -ne 0 ]; then local return_code=$1 shift warn "$@" - notif "$@" + notif set 0 "$@" exit $return_code } fi - -notif () { - info "$@" - printf "$@" > /sys/class/graphics/fb0/notification -} - -clear_notif () { - printf "clear" > /sys/class/graphics/fb0/notification -} diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests index 973cb5b..b992c0a 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests @@ -78,7 +78,7 @@ function launch_tests_up_until_magnet { termfix_all > /dev/null ## Clear all notifs - notif_clear + notif clear ## Test if log file aleady exists if [[ -f $LOG_FILE ]]; then @@ -158,7 +158,7 @@ function launch_tests_up_until_magnet { ## Play 1kHz 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 if [ $? -ne 0 ]; then echo " ERROR: SPEAKER SINE" @@ -166,7 +166,7 @@ function launch_tests_up_until_magnet { return fi sync - notif_clear + notif clear ## Launch prod screen test speaker $PROD_SCREEN_BIN SPEAKER 2>&1 @@ -248,7 +248,7 @@ function launch_tests_after_magnet { #termfix_all > /dev/null ## Clear all notifs - #notif_clear + #notif clear # Log from magnet file echo " Found file: " $MAGNET_DETECTED_FILE diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness index b9d1ebb..f91d542 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/brightness @@ -33,7 +33,7 @@ increase_brightness() { fi # Notif - notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" + notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" } decrease_brightness() { @@ -53,7 +53,7 @@ decrease_brightness() { fi # Notif - notif_set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" + notif set ${NOTIF_DURATION} " BRIGHTNESS: ${new_brightness}%%" } get_brightness() { diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats index a3cbd27..1361686 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats @@ -1,5 +1,5 @@ #!/bin/sh -notif_set 0 " Getting system stats..." +notif set 0 " Getting system stats..." killall -s USR1 system_stats exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot index b121a54..92420a0 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/first_boot @@ -216,29 +216,29 @@ copy_files_to_usb_partition () { } 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 -notif " 2/6 RESIZE ROOT FILESYSTEM" +notif set 0 " 2/6 RESIZE ROOT FILESYSTEM" resize_rootfs_filesystem -notif " 3/6 CREATE SWAP" +notif set 0 " 3/6 CREATE SWAP" create_swap -notif " 4/6 CREATE USB PARTITION" +notif set 0 " 4/6 CREATE USB PARTITION" create_usb_partition -notif " 5/6 FORMAT USB PARTITION" +notif set 0 " 5/6 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 -notif " FIRST BOOT SETUP FINISHED!" +notif set 0 " FIRST BOOT SETUP FINISHED!" fw_setenv first_boot_ok 1 sleep 1 -clear_notif +notif clear diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif new file mode 100755 index 0000000..a9afe6a --- /dev/null +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif @@ -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 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear deleted file mode 100755 index 44f6c1b..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Clear all current notifications - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -printf "clear" > ${NOTIFICATION_DISPLAY} - -exit 0 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp deleted file mode 100755 index d40bd9f..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp +++ /dev/null @@ -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 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set deleted file mode 100755 index bc04835..0000000 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif_set +++ /dev/null @@ -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 diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share index f63d8a5..d0254c8 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/share @@ -54,7 +54,7 @@ mount_share () { # Check if there is a firmware update file if [ -f /mnt/FunKey-*.fwu ]; then warn "found a firmware update file, going into recovery mode" - notif "^^^^^^^^ UPDATING...^^^^^^^^" + notif set 0 "^^^^^^^^ UPDATING...^^^^^^^^" recovery_mode fi diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey index 24056fc..23be9e1 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey @@ -4,7 +4,7 @@ sync # Notif fullscreen "Shutting down" -notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" +notif set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" # Notify system, reboot in progress REBOOTING_FILE="/run/rebooting" diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot index abcc8a3..c45e079 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/snapshot @@ -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/') let last=${last}+1 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 & # Remove lock file diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats index 4e6ad97..8a4bfe3 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/system_stats @@ -10,7 +10,7 @@ function toggle_perform() { let perform=1-${perform} if [ ${perform} -eq 0 ]; then - notif_clear + notif clear notif_dirty=1 fi } @@ -27,13 +27,13 @@ while true; do # Notif if [ ${notif_dirty} -eq 1 ]; then - notif_clear + notif clear notif_dirty=0 else 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 - notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" + notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" fi fi else diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume index f458ceb..89c3bca 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/volume @@ -33,7 +33,7 @@ increase_volume() { fi # Notif - notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" + notif set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" } decrease_volume() { @@ -53,7 +53,7 @@ decrease_volume() { fi # Notif - notif_set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" + notif set ${NOTIF_DURATION} " VOLUME: ${new_volume}%%" } get_volume() { diff --git a/FunKey/package/FCEUX/FCEUX.mk b/FunKey/package/FCEUX/FCEUX.mk index ae49a12..9ab8fa6 100644 --- a/FunKey/package/FCEUX/FCEUX.mk +++ b/FunKey/package/FCEUX/FCEUX.mk @@ -4,7 +4,7 @@ # ################################################################################ -FCEUX_VERSION = f089cec +FCEUX_VERSION = c3ae7fa FCEUX_SITE_METHOD = git FCEUX_SITE = https://github.com/FunKey-Project/fceux.git FCEUX_LICENSE = GPL-2.0 diff --git a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk index fac2040..c475372 100644 --- a/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk +++ b/FunKey/package/PCSX-ReARMed/PCSX-ReARMed.mk @@ -4,7 +4,7 @@ # ################################################################################ -PCSX_REARMED_VERSION = a2f9326 +PCSX_REARMED_VERSION = 2cc6248 PCSX_REARMED_SITE_METHOD = git PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git PCSX_REARMED_LICENSE = GPL-2.0 diff --git a/FunKey/package/PocketSNES/PocketSNES.mk b/FunKey/package/PocketSNES/PocketSNES.mk index 58563a2..b0a3321 100644 --- a/FunKey/package/PocketSNES/PocketSNES.mk +++ b/FunKey/package/PocketSNES/PocketSNES.mk @@ -4,7 +4,7 @@ # ################################################################################ -POCKETSNES_VERSION = 5eb2635 +POCKETSNES_VERSION = c3de812 POCKETSNES_SITE_METHOD = git POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git POCKETSNES_LICENSE = GPL-2.0 diff --git a/FunKey/package/gnuboy/gnuboy.mk b/FunKey/package/gnuboy/gnuboy.mk index cac56ca..d3a0614 100644 --- a/FunKey/package/gnuboy/gnuboy.mk +++ b/FunKey/package/gnuboy/gnuboy.mk @@ -4,7 +4,7 @@ # ################################################################################ -GNUBOY_VERSION = a0d8d26 +GNUBOY_VERSION = f6b8feb GNUBOY_SITE_METHOD = git GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git GNUBOY_LICENSE = GPL-2.0 diff --git a/FunKey/package/gpsp/gpsp.mk b/FunKey/package/gpsp/gpsp.mk index bdbc92e..3e49f7b 100644 --- a/FunKey/package/gpsp/gpsp.mk +++ b/FunKey/package/gpsp/gpsp.mk @@ -4,7 +4,7 @@ # ################################################################################ -GPSP_VERSION = b573bc6 +GPSP_VERSION = 5ab34a8 GPSP_SITE_METHOD = git GPSP_SITE = https://github.com/FunKey-Project/gpsp.git GPSP_LICENSE = GPL-2.0 diff --git a/FunKey/package/mednafen/mednafen.mk b/FunKey/package/mednafen/mednafen.mk index 7c62eac..6cebdbd 100644 --- a/FunKey/package/mednafen/mednafen.mk +++ b/FunKey/package/mednafen/mednafen.mk @@ -4,7 +4,7 @@ # ################################################################################ -MEDNAFEN_VERSION = d535dff +MEDNAFEN_VERSION = 2d9ca9d MEDNAFEN_SITE_METHOD = git MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git MEDNAFEN_LICENSE = GPL-2.0+ diff --git a/FunKey/package/picodrive/picodrive.mk b/FunKey/package/picodrive/picodrive.mk index 2e5c124..b6dca58 100644 --- a/FunKey/package/picodrive/picodrive.mk +++ b/FunKey/package/picodrive/picodrive.mk @@ -4,7 +4,7 @@ # ################################################################################ -PICODRIVE_VERSION = 59b9892 +PICODRIVE_VERSION = 4c09c0b PICODRIVE_SITE_METHOD = git PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git PICODRIVE_LICENSE = MAME diff --git a/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery b/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery index c023ef2..28ca0cb 100755 --- a/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery +++ b/Recovery/board/funkey/rootfs-overlay/etc/init.d/S60recovery @@ -10,7 +10,7 @@ case "$1" in if [ "${keys}" != "0xF83F" ]; then # Automatic firmware update requested - updates=$(ls /mnt/FunKey-*.fwu) + updates=$(ls /mnt/FunKey-*.fwu 2>/dev/null) if [ "x${updates}" = "x" ]; then menu & exit 1 @@ -18,11 +18,11 @@ case "$1" in for file in ${updates} ; do swupdate -i "${file}" if [ $? -ne 0 ]; then - notif_disp 10 " CORRUPTED^ UPDATE FILE" + notif display 10 " CORRUPTED^ UPDATE FILE" rm -f "${file}" fi done - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode else diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils b/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils index a770cca..7a68128 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/lib/utils @@ -18,12 +18,3 @@ if [ $? -ne 0 ]; then exit $return_code } fi - -notif () { - info "$@" - printf "$@" > /sys/class/graphics/fb0/notification -} - -clear_notif () { - printf "clear" > /sys/class/graphics/fb0/notification -} diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness new file mode 100755 index 0000000..f91d542 --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/brightness @@ -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 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats index 5c4638d..fe252a4 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/display_notif_system_stats @@ -1,5 +1,5 @@ #!/bin/sh -notif_set 0 "Getting system stats..." +notif set 0 "Getting system stats..." killall -s USR1 system_stats exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu index 146e486..d23b5c6 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/menu @@ -11,8 +11,6 @@ getkey() { # Display meny item menu_display () { local entry=${1} - - #clear_notif case ${entry} in 0) @@ -92,7 +90,7 @@ menu_display () { message=" SHUTDOWN" ;; esac - notif "${message}" + notif set 0 "${message}" } # Run menu item @@ -114,7 +112,7 @@ menu_run () { umount ${rootfs_mount} version_recovery=$(grep Recovery /etc/sw-versions | cut -f 2) 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) @@ -122,31 +120,31 @@ menu_run () { # USB mount/unmount mount | grep -q /dev/mmcblk0p4 if [ $? -eq 0 ]; then - notif "${message}..." + notif set 0 "${message}..." share start if [ $? -ne 0 ]; then - notif "${message}...^CANNOT MOUNT USB!" + notif set 0 "${message}...^CANNOT MOUNT USB!" else message=" USB UNMOUNT" - notif "${message}" + notif set 0 "${message}" fi else - notif "${message}..." + notif set 0 "${message}..." share stop if [ $? -ne 0 ]; then - notif "${message}...^CANNOT UNMOUNT USB!" + notif set 0 "${message}...^CANNOT UNMOUNT USB!" else for file in $(ls /mnt/FunKey-*.fwu); do swupdate -i "${file}" if [ $? -ne 0 ]; then - notif_disp 10 "${message}...^ CORRUPTED^ UPDATE FILE" + notif set 0 display 10 "${message}...^ CORRUPTED^ UPDATE FILE" rm -f "${file}" - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode fi done message=" USB MOUNT" - notif "${message}" + notif set 0 "${message}" fi fi ;; @@ -156,23 +154,23 @@ menu_run () { # USB check mount | grep -q /dev/mmcblk0p4 if [ $? -eq 0 ]; then - notif "${message}..." + notif set 0 "${message}..." umount /mnt >/dev/null 2>&1 if [ $? -ne 0 ]; then - notif "${message}...^CANNOT CHECK USB!" + notif set 0 "${message}...^CANNOT CHECK USB!" fi fsck.fat -a -v -w /dev/mmcblk0p4 if [ $? -ne 0 ]; then - notif "${message}...^CANNOT CHECK USB!" + notif set 0 "${message}...^CANNOT CHECK USB!" fi mount /mnt if [ $? -ne 0 ]; then - notif "${message}...^CANNOT CHECK USB!" + notif set 0 "${message}...^CANNOT CHECK USB!" else - notif "${message} DONE" + notif set 0 "${message} DONE" fi else - notif "${message}...^CANNOT CHECK USB WHEN MOUNTED!" + notif set 0 "${message}...^CANNOT CHECK USB WHEN MOUNTED!" fi ;; @@ -181,7 +179,7 @@ menu_run () { # USB format mount | grep -q /dev/mmcblk0p4 if [ $? -eq 0 ]; then - notif "${message}...^PRESS A TO CONFIRM" + notif set 0 "${message}...^PRESS A TO CONFIRM" while true; do case $(getkey) in 1e0001|1e0002) @@ -189,9 +187,9 @@ menu_run () { mkfs.vfat /dev/mmcblk0p4 && mount /mnt if [ $? -ne 0 ]; then - notif "${message}...^CANNOT FORMAT USB!" + notif set 0 "${message}...^CANNOT FORMAT USB!" else - notif "${message} DONE" + notif set 0 "${message} DONE" fi break ;; @@ -200,13 +198,13 @@ menu_run () { ;; *) - notif "${message}...^ABORTED!" + notif set 0 "${message}...^ABORTED!" break ;; esac done else - notif "${message}...^CANNOT FORMAT USB WHEN MOUNTED!" + notif set 0 "${message}...^CANNOT FORMAT USB WHEN MOUNTED!" fi ;; @@ -222,9 +220,9 @@ menu_run () { touch /mnt/usbnet message=" NETWORK: ENABLED" fi - notif "${message}" + notif set 0 "${message}" else - notif "${message}...^CANNOT CHANGE NET IF MOUNTED!" + notif set 0 "${message}...^CANNOT CHANGE NET IF MOUNTED!" fi ;; @@ -246,7 +244,7 @@ menu_run () { fw_setenv assembly_tests 1 message=" FACTORY TESTS: ENABLED" fi - notif "${message}" + notif set 0 "${message}" ;; 7) @@ -260,16 +258,16 @@ menu_run () { fw_setenv first_boot_ok 1 message=" FIRST BOOT: DISABLED" fi - notif "${message}" + notif set 0 "${message}" ;; 8) - notif "^^^^^^^^ RESTARTING...^^^^^^^^" + notif set 0 "^^^^^^^^ RESTARTING...^^^^^^^^" normal_mode ;; 9) - notif "^^^^^^^^ SHUTDOWN...^^^^^^^^" + notif set 0 "^^^^^^^^ SHUTDOWN...^^^^^^^^" poweroff ;; esac diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif new file mode 100755 index 0000000..2a16366 --- /dev/null +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif @@ -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 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear deleted file mode 100755 index 44f6c1b..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_clear +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Clear all current notifications - -NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification - -printf "clear" > ${NOTIFICATION_DISPLAY} - -exit 0 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp deleted file mode 100755 index d40bd9f..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_disp +++ /dev/null @@ -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 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set deleted file mode 100755 index bc04835..0000000 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/notif_set +++ /dev/null @@ -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 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey index 0d9c312..b22fdb7 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/shutdown_funkey @@ -1,7 +1,7 @@ #!/bin/sh # Notif fullscreen "Shutting down" -notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" +notif set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^" # Kill Emulators #kill_emulators >/dev/null 2>&1 diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot index abcc8a3..c45e079 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/snapshot @@ -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/') let last=${last}+1 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 & # Remove lock file diff --git a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats index 4e6ad97..8a4bfe3 100755 --- a/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats +++ b/Recovery/board/funkey/rootfs-overlay/usr/local/sbin/system_stats @@ -10,7 +10,7 @@ function toggle_perform() { let perform=1-${perform} if [ ${perform} -eq 0 ]; then - notif_clear + notif clear notif_dirty=1 fi } @@ -27,13 +27,13 @@ while true; do # Notif if [ ${notif_dirty} -eq 1 ]; then - notif_clear + notif clear notif_dirty=0 else 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 - notif_set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" + notif set 0 " CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%" fi fi else