mirror of
https://github.com/FunKey-Project/FunKey-OS.git
synced 2026-03-19 10:22:46 +01:00
change for new notif script
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
78
FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif
Executable file
78
FunKey/board/funkey/rootfs-overlay/usr/local/sbin/notif
Executable 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
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Clear all current notifications
|
||||
|
||||
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
|
||||
|
||||
printf "clear" > ${NOTIFICATION_DISPLAY}
|
||||
|
||||
exit 0
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user