Cleanup calling - mostly working; misc cleanup scripts; add vibrate program

This commit is contained in:
Miles Alan 2020-05-04 19:27:22 -05:00
parent fd286101d8
commit 22d974f22f
17 changed files with 366 additions and 176 deletions

View file

@ -1,30 +1,24 @@
#!/usr/bin/env sh
WIN=$(xdotool getwindowfocus)
INCOMINGCALL=$(cat /tmp/sxmo_incomingcall || echo NOCALL)
programchoicesinit() {
WMCLASS="${1:-$(xprop -id $(xdotool getactivewindow) | grep WM_CLASS | cut -d ' ' -f3-)}"
# Default
# Default system menu (no matches)
CHOICES="$(echo "
Scripts ^ 0 ^ sxmo_appmenu.sh scripts
Apps ^ 0 ^ sxmo_appmenu.sh applications
Volume ↑ ^ 1 ^ sxmo_vol.sh up
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Dialer ^ 1 ^ sxmo_phonecaller.exp dial
Volume ↑ ^ 1 ^ sxmo_vol.sh up
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Dialer ^ 1 ^ sxmo_modemcall.sh dial
Texts ^ 0 ^ sxmo_readtexts.sh
Camera ^ 0 ^ sxmo_camera.sh
Wifi ^ 0 ^ st -e "nmtui"
System Config ^ 0 ^ sxmo_appmenu.sh control
Logout ^ 0 ^ pkill -9 dwm
Close Menu ^ 0 ^ quit
")" && WINNAME=Sys
# E.g. for the system menu if there's an incoming call pop it on top of menu
echo "$INCOMINGCALL" | grep -v NOCALL && CHOICES="$(echo "
Pickup $INCOMINGCALL ^ 0 ^ sxmo_phonecaller.exp pickup $INCOMINGCALL
")""$CHOICES"
# Apps menu
echo $WMCLASS | grep -i "applications" && CHOICES="$(echo "
Surf ^ 0 ^ surf
NetSurf ^ 0 ^ netsurf
@ -33,30 +27,31 @@ programchoicesinit() {
St ^ 0 ^ st
Firefox ^ 0 ^ firefox
Foxtrotgps ^ 0 ^ foxtrotgps
Close Menu ^ 0 ^ quit
")" && WINNAME=Apps
")" && WINNAME=Apps && return
# Scripts menu
echo $WMCLASS | grep -i "scripts" && CHOICES="$(echo "
Timer ^ 0 ^ sxmo_timermenu.sh
Youtube ^ 0 ^ sxmo_youtube.sh
Youtube (Audio) ^ 0 ^ sxmo_youtube.sh --no-video
Weather ^ 0 ^ sxmo_weather.sh
RSS ^ 0 ^ sxmo_rss.sh
Close Menu ^ 0 ^ quit
")" && WINNAME=Scripts
")" && WINNAME=Scripts && return
# System Control menu
echo $WMCLASS | grep -i "control" && CHOICES="$(echo "
Volume ↑ ^ 1 ^ sxmo_vol.sh up
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Brightesss ↑ ^ 1 ^ sxmo_brightness.sh up
Brightness ↓ ^ 1 ^ sxmo_brightness.sh down
Modem Info ^ 1 ^ st -e 'mmcli -m 0 && read'
Rotate ^ 1 ^ rotate
Wifi ^ 0 ^ st -e "nmtui"
Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh
Close Menu ^ 0 ^ quit
")" && WINNAME=Control
Volume ↑ ^ 1 ^ sxmo_vol.sh up
Volume ↓ ^ 1 ^ sxmo_vol.sh down
Brightesss ↑ ^ 1 ^ sxmo_brightness.sh up
Brightness ↓ ^ 1 ^ sxmo_brightness.sh down
Modem $(pgrep -f sxmo_modemmonitor.sh >/dev/null && echo -n "On → Off" || echo -n "Off → On") ^ 1 ^ sxmo_modemmonitortoggle.sh
Modem Info ^ 1 ^ sxmo_modeminfo.sh
Rotate ^ 1 ^ rotate
Wifi ^ 0 ^ st -e "nmtui"
Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh
")" && WINNAME=Control && return
# MPV
echo $WMCLASS | grep -i "mpv" && CHOICES="$(echo "
Pause ^ 0 ^ key space
Seek ← ^ 1 ^ key Left
@ -69,30 +64,27 @@ programchoicesinit() {
Loopmark ^ 1 ^ key l
Info ^ 1 ^ key i
Seek Info ^ 1 ^ key o
Close Menu ^ 0 ^ quit
")" && WINNAME=Mpv
")" && WINNAME=Mpv && return
# St
echo $WMCLASS | grep -i "st-256color" && CHOICES="$(echo "
Pastecomplete ^ 0 ^ key Ctrl+Shift+u
Copycomplete ^ 0 ^ key Ctrl+Shift+i
Paste ^ 0 ^ key Ctrl+Shift+v
Pipe Data ^ 0 ^
Zoom + ^ 1 ^ key Ctrl+Shift+Prior
Zoom - ^ 1 ^ key Ctrl+Shift+Next
Scroll ↑ ^ 1 ^ key Shift+Prior
Scroll ↓ ^ 1 ^ key Shift+Next
Scroll ↑ ^ 1 ^ key Ctrl+Shift+b
Scroll ↓ ^ 1 ^ key Ctrl+Shift+f
Invert ^ 1 ^ key Ctrl+Shift+x
Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys
Close Menu ^ 0 ^ quit
")" && WINNAME=st
")" && WINNAME=st && return
# St hotkeys
echo $WMCLASS | grep -i "sthotkeys" && CHOICES="$(echo "
Send Ctrl-C ^ 0 ^ key Ctrl+c
Send Ctrl-L ^ 0 ^ key Ctrl+l
Send Ctrl-D ^ 0 ^ key Ctrl+d
Close Menu ^ 0 ^ quit
")" && WINNAME=st
")" && WINNAME=st && return
# Surf
echo $WMCLASS | grep surf && CHOICES="$(echo "
@ -107,18 +99,27 @@ programchoicesinit() {
Search ^ 1 ^ key Ctrl+f
History ← ^ 1 ^ key Ctrl+h
History → ^ 1 ^ key Ctrl+l
Close Menu ^ 0 ^ quit
")" && WINNAME=surf
")" && WINNAME=surf && return
# Netsurf
echo $WMCLASS | grep -i netsurf && CHOICES="$(echo "
Pipe URL ^ 0 ^ sxmo_urlhandler.sh
Zoom + ^ 1 ^ key Ctrl+plus
Zoom - ^ 1 ^ key Ctrl+minus
History ← ^ 1 ^ key Alt+Left
History → ^ 1 ^ key Alt+Right
Close Menu ^ 0 ^ quit
")" && WINNAME=netsurf
")" && WINNAME=netsurf && return
# Firefox
echo $WMCLASS | grep -i firefox && CHOICES="$(echo "
Pipe URL ^ 0 ^ sxmo_urlhandler.sh
Zoom + ^ 1 ^ key Ctrl+plus
Zoom - ^ 1 ^ key Ctrl+minus
History ← ^ 1 ^ key Alt+Left
History → ^ 1 ^ key Alt+Right
")" && WINNAME=netsurf && return
# Foxtrot GPS
echo $WMCLASS | grep -i foxtrot && CHOICES="$(echo "
Zoom + ^ 1 ^ key i
Zoom - ^ 1 ^ key o
@ -127,8 +128,33 @@ programchoicesinit() {
Route ^ 0 ^ key r
Gmaps Transfer ^ 0 ^ key o
Copy Cords ^ 0 ^ key o
Close Menu ^ 0 ^ quit
")" && WINNAME=gps
")" && WINNAME=gps && return
}
getprogchoices() {
# E.g. sets CHOICES var
programchoicesinit $@
# Decorate menu at top w/ incoming call entry if present
INCOMINGCALL=$(cat /tmp/sxmo_incomingcall || echo NOCALL)
echo "$INCOMINGCALL" | grep -v NOCALL && CHOICES="$(echo "
Pickup $(echo $INCOMINGCALL | cut -d: -f2) ^ 0 ^ sxmo_modemcall.sh pickup $(echo $INCOMINGCALL | cut -d: -f1)
$CHOICES
")"
# Decorate menu at bottom w/ system menu entry if not system menu
echo $WINNAME | grep -v Sys && CHOICES="
$CHOICES
System Menu ^ 0 ^ sxmo_appmenu.sh sys
"
# Decorate menu at bottom w/ close menu entry
CHOICES="
$CHOICES
Close Menu ^ 0 ^ quit
"
PROGCHOICES="$(echo "$CHOICES" | xargs -0 echo | sed '/^[[:space:]]*$/d' | awk '{$1=$1};1')"
}
rotate() {
@ -145,33 +171,30 @@ quit() {
exit 0
}
boot() {
mainloop() {
DMENUIDX=0
PICKED=""
pgrep -f sxmo_appmenu.sh | grep -Ev "^${$}$" | xargs kill -9
pkill -9 dmenu
}
ARGS="$@"
mainloop() {
while :
do
PICKED=$(
echo "$CHOICES" |
xargs -0 echo |
# E.g. sets PROGCHOICES
getprogchoices $ARGS
PICKED="$(
echo "$PROGCHOICES" |
cut -d'^' -f1 |
sed '/^[[:space:]]*$/d' |
awk '{$1=$1};1' |
dmenu -idx $DMENUIDX -l 14 -c -fn "Terminus-30" -p "$WINNAME"
)
LOOP=$(echo "$CHOICES" | grep "$PICKED" | cut -d '^' -f2)
CMD=$(echo "$CHOICES" | grep "$PICKED" | cut -d '^' -f3)
DMENUIDX=$(echo $(echo "$CHOICES" | grep -n "$PICKED" | cut -d ':' -f1) - 1 | bc)
)"
LOOP="$(echo "$PROGCHOICES" | grep -F "$PICKED" | cut -d '^' -f2)"
CMD="$(echo "$PROGCHOICES" | grep -F "$PICKED" | cut -d '^' -f3)"
DMENUIDX="$(echo "$PROGCHOICES" | grep -F -n "$PICKED" | cut -d ':' -f1)"
echo "Eval: <$CMD> from picked <$PICKED> with loop <$LOOP>"
eval $CMD
echo $LOOP | grep 1 || quit
done
}
boot
programchoicesinit $@
mainloop
pgrep -f sxmo_appmenu.sh | grep -Ev "^${$}$" | xargs kill -9
pkill -9 dmenu
mainloop $@

View file

@ -1,25 +1,29 @@
#!/usr/bin/env sh
MAX=10
[ -e /sys/class/backlight/edp-backlight ] && DEV=/sys/class/backlight/edp-backlight
[ -e /sys/devices/platform/backlight/backlight/backlight ] && DEV=/sys/devices/platform/backlight/backlight/backlight
MAX=$(cat $DEV/max_brightness)
MIN=2
STEP=$(echo "($MAX - $MIN) / 10" | bc)
setdelta() {
sxmo_setpinebacklight $(
cat /sys/class/backlight/backlight/brightness |
cat $DEV/brightness |
xargs -IB echo B $1 |
bc |
xargs -INUM echo -e "$MIN\nNUM" | sort -n | tail -n1 |
xargs -INUM echo -e "$MAX\nNUM" | sort -n | head -n1
)
sxmo_notify.sh 200 "Backlight $(cat /sys/class/backlight/backlight/brightness)/10"
sxmo_notify.sh 200 "Backlight $(cat $DEV/brightness)/${MAX}"
}
up() {
setdelta "+1"
setdelta "+${STEP}"
}
down() {
setdelta "-1"
setdelta "-${STEP}"
}
$1 $2

View file

@ -1,23 +0,0 @@
#!/usr/bin/env sh
INPUT="$(cat)"
pidof svkbd-sxmo || svkbd-sxmo &
RESULT="$(
echo "$(
echo "Close Menu" &&
echo "$INPUT" |\
grep -Eo '\S+' |\
tr -d '[:blank:]' |\
sort |\
uniq
)" | dmenu -p Type -l 10 -i -c -fn Terminus-20
)"
pkill svkbd-sxmo
if [[ "$RESULT" = "Close Menu" ]]; then
exit 0
else
xdotool type "$RESULT"
fi

View file

@ -0,0 +1,39 @@
#!/usr/bin/env sh
INPUT="$(cat)"
pidof svkbd-sxmo || svkbd-sxmo &
capfirstchar() {
awk -F -vOFS= {$1=toupper($1);print $0}
}
RESULT="$(
echo "$(
echo "Close Menu" &&
echo "$INPUT" |\
grep -Eo '\S+' |\
tr -d '[:blank:]' |\
sort |\
uniq
)" | dmenu -p $(echo $1 | capfirstchar) -l 10 -i -c -fn Terminus-20
)"
pkill svkbd-sxmo
copy() {
if [[ "$RESULT" = "Close Menu" ]]; then
exit 0
else
echo "$RESULT" | xsel -i
fi
}
type() {
if [[ "$RESULT" = "Close Menu" ]]; then
exit 0
else
xdotool type "$RESULT"
fi
}
$@

View file

@ -1,15 +1,23 @@
#!/usr/bin/env sh
pgrep -f sxmo_statusbar.sh | grep -v $$ | xargs kill -9
UPDATEFILE=/tmp/sxmo_bar
touch $UPDATEFILE
while :
do
# M symbol if modem monitoring is on
MODEMMON=""
pgrep -f sxmo_modemmonitor.sh && MODEMMON="M "
# Battery pct
PCT=$(cat /sys/class/power_supply/*-battery/capacity)
BATSTATUS=$(
cat /sys/class/power_supply/*-battery/status |
cut -c1
)
# Volume
VOL=$(
echo "$(amixer sget Headphone || amixer sget Speaker)" |
grep -oE '([0-9]+)%' |
@ -18,11 +26,12 @@ do
xargs printf %.0f
)
# Time
TIME=$(date +%R)
BAR=" V${VOL} ${BATSTATUS}${PCT}% ${TIME}"
BAR=" ${MODEMMON}V${VOL} ${BATSTATUS}${PCT}% ${TIME}"
xsetroot -name "$BAR"
inotifywait -e MODIFY $UPDATEFILE & sleep 5 & wait -n
inotifywait -e MODIFY $UPDATEFILE & sleep 30 & wait -n
pgrep -P $$ | xargs kill -9
done

View file

@ -1,23 +1,26 @@
#!/usr/bin/env sh
device() {
amixer sget Headphone && echo Headphone || echo Speaker
amixer sget Headphone > /dev/null && echo Headphone || echo Speaker
}
incvol() {
notify() {
sxmo_notify.sh 200 "Volume $(
amixer get "$(device)" |
grep -oE '([0-9]+)%' |
tr -d ' %' |
awk '{ s += $1; c++ } END { print s/c }' |
xargs printf %.0f
)"
echo 1 > /tmp/sxmo_bar
}
up() {
amixer set $(device) 1+
echo 1 > /tmp/sxmo_bar
notify
}
decvol() {
down() {
amixer set $(device) 1-
echo 1 > /tmp/sxmo_bar
notify
}
echo $1 | grep up && echo 1 > /tmp/sxmo_bar && incvol
echo $1 | grep down && echo 1 > /tmp/sxmo_bar && decvol
sxmo_notify.sh 200 "Volume $(
echo "$(amixer sget Headphone || amixer sget Speaker)" |
grep -oE '([0-9]+)%' |
tr -d ' %' |
awk '{ s += $1; c++ } END { print s/c }' |
xargs printf %.0f
)"
$@

View file

@ -10,7 +10,7 @@ alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore
#xset r off
# E.g. for PBP
synclient TapButton1=1 TapButton2=3 TapButton3=2
synclient TapButton1=1 TapButton2=3 TapButton3=2 MinSpeed=0.25
keynav &
conky -c /usr/share/sxmo/conky.conf -d