Various progess on calling & texting; reorganize scripts dirs by category
This commit is contained in:
parent
334c74ad39
commit
ae983ef8c8
35 changed files with 1002 additions and 221 deletions
177
scripts/core/sxmo_appmenu.sh
Executable file
177
scripts/core/sxmo_appmenu.sh
Executable file
|
@ -0,0 +1,177 @@
|
|||
#!/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
|
||||
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
|
||||
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"
|
||||
|
||||
echo $WMCLASS | grep -i "applications" && CHOICES="$(echo "
|
||||
Surf ^ 0 ^ surf
|
||||
NetSurf ^ 0 ^ netsurf
|
||||
Sacc ^ 0 ^ st -e sacc i-logout.cz/1/bongusta
|
||||
W3M ^ 0 ^ st -e w3m duck.com
|
||||
St ^ 0 ^ st
|
||||
Firefox ^ 0 ^ firefox
|
||||
Foxtrotgps ^ 0 ^ foxtrotgps
|
||||
Close Menu ^ 0 ^ quit
|
||||
")" && WINNAME=Apps
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
echo $WMCLASS | grep -i "mpv" && CHOICES="$(echo "
|
||||
Pause ^ 0 ^ key space
|
||||
Seek ← ^ 1 ^ key Left
|
||||
Seek → ^ 1 ^ key Right
|
||||
App Volume ↑ ^ 1 ^ key 0
|
||||
App Volume ↓ ^ 1 ^ key 9
|
||||
Speed ↑ ^ 1 ^ key bracketright
|
||||
Speed ↓ ^ 1 ^ key bracketleft
|
||||
Screenshot ^ 1 ^ key s
|
||||
Loopmark ^ 1 ^ key l
|
||||
Info ^ 1 ^ key i
|
||||
Seek Info ^ 1 ^ key o
|
||||
Close Menu ^ 0 ^ quit
|
||||
")" && WINNAME=Mpv
|
||||
|
||||
# St
|
||||
echo $WMCLASS | grep -i "st-256color" && CHOICES="$(echo "
|
||||
Pastecomplete ^ 0 ^ key Ctrl+Shift+u
|
||||
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
|
||||
Invert ^ 1 ^ key Ctrl+Shift+x
|
||||
Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys
|
||||
Close Menu ^ 0 ^ quit
|
||||
")" && WINNAME=st
|
||||
|
||||
# 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
|
||||
|
||||
# Surf
|
||||
echo $WMCLASS | grep surf && CHOICES="$(echo "
|
||||
Navigate ^ 0 ^ key Ctrl+g
|
||||
Link Menu ^ 0 ^ key Ctrl+d
|
||||
Pipe URL ^ 0 ^ sxmo_urlhandler.sh
|
||||
Zoom + ^ 1 ^ key Ctrl+Shift+k
|
||||
Zoom - ^ 1 ^ key Ctrl+Shift+j
|
||||
Scroll ↑ ^ 1 ^ key Ctrl+space
|
||||
Scroll ↓ ^ 1 ^ key Ctrl+b
|
||||
JS Toggle ^ 1 ^ key Ctrl+Shift+s
|
||||
Search ^ 1 ^ key Ctrl+f
|
||||
History ← ^ 1 ^ key Ctrl+h
|
||||
History → ^ 1 ^ key Ctrl+l
|
||||
Close Menu ^ 0 ^ quit
|
||||
")" && WINNAME=surf
|
||||
|
||||
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
|
||||
|
||||
echo $WMCLASS | grep -i foxtrot && CHOICES="$(echo "
|
||||
Zoom + ^ 1 ^ key i
|
||||
Zoom - ^ 1 ^ key o
|
||||
Panel toggle ^ 1 ^ key m
|
||||
Autocenter toggle ^ 0 ^ key a
|
||||
Route ^ 0 ^ key r
|
||||
Gmaps Transfer ^ 0 ^ key o
|
||||
Copy Cords ^ 0 ^ key o
|
||||
Close Menu ^ 0 ^ quit
|
||||
")" && WINNAME=gps
|
||||
}
|
||||
|
||||
rotate() {
|
||||
xrandr | grep primary | cut -d' ' -f 5 | grep right && xrandr -o normal || xrandr -o right
|
||||
}
|
||||
|
||||
key() {
|
||||
xdotool windowactivate $WIN
|
||||
xdotool key --clearmodifiers $1
|
||||
#--window $WIN
|
||||
}
|
||||
|
||||
quit() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
boot() {
|
||||
DMENUIDX=0
|
||||
PICKED=""
|
||||
pgrep -f sxmo_appmenu.sh | grep -Ev "^${$}$" | xargs kill -9
|
||||
pkill -9 dmenu
|
||||
}
|
||||
|
||||
mainloop() {
|
||||
while :
|
||||
do
|
||||
PICKED=$(
|
||||
echo "$CHOICES" |
|
||||
xargs -0 echo |
|
||||
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)
|
||||
eval $CMD
|
||||
echo $LOOP | grep 1 || quit
|
||||
done
|
||||
}
|
||||
|
||||
boot
|
||||
programchoicesinit $@
|
||||
mainloop
|
||||
|
4
scripts/core/sxmo_blinkled.sh
Executable file
4
scripts/core/sxmo_blinkled.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
sxmo_setpineled $1 150
|
||||
sleep 0.01
|
||||
sxmo_setpineled $1 0
|
25
scripts/core/sxmo_brightness.sh
Executable file
25
scripts/core/sxmo_brightness.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env sh
|
||||
MAX=10
|
||||
MIN=2
|
||||
|
||||
setdelta() {
|
||||
sxmo_setpinebacklight $(
|
||||
cat /sys/class/backlight/backlight/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"
|
||||
}
|
||||
|
||||
up() {
|
||||
setdelta "+1"
|
||||
|
||||
}
|
||||
|
||||
down() {
|
||||
setdelta "-1"
|
||||
}
|
||||
|
||||
$1 $2
|
3
scripts/core/sxmo_camera.sh
Executable file
3
scripts/core/sxmo_camera.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env sh
|
||||
media-ctl -d /dev/media1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720]'
|
||||
mpv --video-rotate=90 av://v4l2:/dev/video1
|
6
scripts/core/sxmo_dimscreentoggle.sh
Executable file
6
scripts/core/sxmo_dimscreentoggle.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
OLDB=$(cat /tmp/oldscreenb || echo 10)
|
||||
DIMB=2
|
||||
CURB=$(cat /sys/devices/platform/backlight/backlight/backlight/brightness)
|
||||
|
||||
[[ $CURB == $DIMB ]] && sxmo_setpinebacklight $OLDB || sxmo_setpinebacklight $DIMB
|
6
scripts/core/sxmo_dmenu_with_kb.sh
Executable file
6
scripts/core/sxmo_dmenu_with_kb.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
pidof svkbd-sxmo || svkbd-sxmo &
|
||||
OUTPUT="$(cat | dmenu -t $@)"
|
||||
pkill svkbd-sxmo
|
||||
echo "$OUTPUT"
|
5
scripts/core/sxmo_edit_screen.sh
Executable file
5
scripts/core/sxmo_edit_screen.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
tmpfile=$(mktemp /tmp/st-edit.XXXXXX)
|
||||
trap 'rm "$tmpfile"' 0 1 15
|
||||
cat > "$tmpfile"
|
||||
st -e "$EDITOR" "$tmpfile"
|
12
scripts/core/sxmo_notify.sh
Executable file
12
scripts/core/sxmo_notify.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env sh
|
||||
HEIGHT=30
|
||||
W=$1
|
||||
FULLW=$(
|
||||
xdpyinfo |
|
||||
grep 'dimensions' |
|
||||
egrep -o "[0-9]+x[0-9]+ pixels" |
|
||||
sed "s/x.*//"
|
||||
)
|
||||
OFFX=$(echo $FULLW - $W - 2 | bc)
|
||||
|
||||
sh -c "echo $2 | dzen2 -p 2 -h $HEIGHT -x $OFFX -y 30" &
|
23
scripts/core/sxmo_pastecomplete.sh
Executable file
23
scripts/core/sxmo_pastecomplete.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/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
|
28
scripts/core/sxmo_statusbar.sh
Executable file
28
scripts/core/sxmo_statusbar.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env sh
|
||||
UPDATEFILE=/tmp/sxmo_bar
|
||||
touch $UPDATEFILE
|
||||
|
||||
while :
|
||||
do
|
||||
PCT=$(cat /sys/class/power_supply/axp20x-battery/capacity)
|
||||
BATSTATUS=$(
|
||||
cat /sys/class/power_supply/axp20x-battery/status |
|
||||
cut -b0
|
||||
)
|
||||
|
||||
VOL=$(
|
||||
amixer sget Headphone |
|
||||
grep -oE '([0-9]+)%' |
|
||||
tr -d ' %' |
|
||||
awk '{ s += $1; c++ } END { print s/c }' |
|
||||
xargs printf %.0f
|
||||
)
|
||||
|
||||
TIME=$(date +%R)
|
||||
|
||||
BAR=" V${VOL} ${BATSTATUS}${PCT}% ${TIME}"
|
||||
xsetroot -name "$BAR"
|
||||
|
||||
inotifywait -e MODIFY $UPDATEFILE & sleep 5 & wait -n
|
||||
pgrep -P $$ | xargs kill -9
|
||||
done
|
79
scripts/core/sxmo_surf_linkselect.sh
Executable file
79
scripts/core/sxmo_surf_linkselect.sh
Executable file
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env sh
|
||||
# surf_linkselect.sh:
|
||||
# Usage: curl somesite.com | surf_linkselect [SURFWINDOWID] [PROMPT]
|
||||
# Deps: xmllint, dmenu
|
||||
# Info:
|
||||
# Designed to be used w/ surf externalpipe patch. Enables keyboard-only
|
||||
# link selection via dmenu. Given HTML stdin, extracts links one per line
|
||||
# Selected link is normalized based on current URI and printed to STDOUT.
|
||||
# Pipe the result to a new surf or xprop _SURF_URI accordingly.
|
||||
SURF_WINDOW="${1:-$(xprop -root | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* //p')}"
|
||||
DMENU_PROMPT="${2:-Link}"
|
||||
|
||||
function dump_links_with_titles() {
|
||||
awk '{
|
||||
input = $0;
|
||||
|
||||
$0 = input;
|
||||
gsub("<[^>]*>", "");
|
||||
gsub(/[ ]+/, " ");
|
||||
gsub("&", "\\&");
|
||||
gsub("<", "<");
|
||||
gsub(">", ">");
|
||||
$1 = $1;
|
||||
title = ($0 == "" ? "None" : $0);
|
||||
|
||||
$0 = input;
|
||||
match($0, /\<[ ]*[aA][^>]* [hH][rR][eE][fF]=["]([^"]+)["]/, linkextract);
|
||||
$0 = linkextract[1];
|
||||
gsub(/^[ \t]+/,"");
|
||||
gsub(/[ \t]+$/,"");
|
||||
gsub("[ ]", "%20");
|
||||
link = $0;
|
||||
|
||||
if (link != "") {
|
||||
print title ": " link;
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
function link_normalize() {
|
||||
URI=$1
|
||||
awk -v uri=$URI '{
|
||||
gsub("&", "\\&");
|
||||
|
||||
if ($0 ~ /^https?:\/\// || $0 ~ /^\/\/.+$/) {
|
||||
print $0;
|
||||
} else if ($0 ~/^#/) {
|
||||
gsub(/[#?][^#?]+/, "", uri);
|
||||
print uri $0;
|
||||
} else if ($0 ~/^\//) {
|
||||
split(uri, uri_parts, "/");
|
||||
print uri_parts[3] $0;
|
||||
} else {
|
||||
gsub(/[#][^#]+/, "", uri);
|
||||
uri_parts_size = split(uri, uri_parts, "/");
|
||||
delete uri_parts[uri_parts_size];
|
||||
for (v in uri_parts) {
|
||||
uri_pagestripped = uri_pagestripped uri_parts[v] "/"
|
||||
}
|
||||
print uri_pagestripped $0;
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
function link_select() {
|
||||
tr '\n\r' ' ' |
|
||||
xmllint --html --xpath "//a" - |
|
||||
dump_links_with_titles |
|
||||
awk '!x[$0]++' |
|
||||
# sort | uniq
|
||||
dmenu -p "$DMENU_PROMPT" -l 10 -i -c |
|
||||
awk -F' ' '{print $NF}' |
|
||||
link_normalize $(xprop -id $SURF_WINDOW _SURF_URI | cut -d '"' -f 2)
|
||||
}
|
||||
|
||||
pidof svkbd-sxmo || svkbd-sxmo &
|
||||
VAL="$(link_select)"
|
||||
pkill svkbd-sxmo
|
||||
echo "$VAL"
|
6
scripts/core/sxmo_upgrade.sh
Executable file
6
scripts/core/sxmo_upgrade.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
echo "Updating all packages from repositories"
|
||||
sudo apk update
|
||||
|
||||
echo "Upgrading all packages"
|
||||
sudo apk upgrade
|
45
scripts/core/sxmo_urlhandler.sh
Executable file
45
scripts/core/sxmo_urlhandler.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
if [[ ! -z "$1" ]]
|
||||
then
|
||||
# E.g. passed liked: sxmo_urlhandler.sh http://foo.com
|
||||
URL=$1
|
||||
else
|
||||
# Surf
|
||||
WINDOW="$(xprop -root | sed -n '/^_NET_ACTIVE_WINDOW/ s/.* //p')"
|
||||
SURFURL=`xprop -id $WINDOW | grep URI | awk '{print $3}' | sed 's/\"//g'`
|
||||
if [[ ! -z "$SURFURL" ]]
|
||||
then
|
||||
URL="$SURFURL"
|
||||
fi
|
||||
|
||||
# Is normal browser? (FF or Netsurf) - use Ctrl-L Ctrl-C to copy URL
|
||||
ISNORMBROWS=`xprop -id $(xdotool getactivewindow) | grep -E 'WM_CLASS.*(Netsurf|Firefox)'`
|
||||
if [[ ! -z "$ISNORMBROWS" ]]
|
||||
then
|
||||
xdotool key --clearmodifiers --delay 20 "ctrl+l" "ctrl+c"
|
||||
sleep 0.2
|
||||
URL="$(xclip -o)"
|
||||
fi
|
||||
fi
|
||||
|
||||
COMMAND=$(
|
||||
echo "
|
||||
w3m URL
|
||||
mpv -v URL
|
||||
mpv -v --ytdl-format='[height<420]' URL
|
||||
firefox -new-window URL
|
||||
netsurf URL
|
||||
surf URL
|
||||
echo URL | xclip -i
|
||||
youtube-dl -o- URL | mpv -v -
|
||||
youtube-dl URL
|
||||
curl URL | vis -
|
||||
wget URL
|
||||
aria2c URL
|
||||
" | sed "s/URL/'URL'/g" | sed -e '/^\s*$/d' | sed -e 's/^\s*//' | dmenu -p "Pipe URL" -c -l 10
|
||||
)
|
||||
[[ -z "$COMMAND" ]] && exit 1
|
||||
|
||||
RUN=$(echo $URL | xargs -IURL echo "$COMMAND")
|
||||
st -e sh -c "$RUN"
|
19
scripts/core/sxmo_vol.sh
Executable file
19
scripts/core/sxmo_vol.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env sh
|
||||
incvol() {
|
||||
amixer set Headphone 1+
|
||||
echo 1 > /tmp/sxmo_bar
|
||||
}
|
||||
decvol() {
|
||||
amixer set Headphone 1-
|
||||
echo 1 > /tmp/sxmo_bar
|
||||
}
|
||||
|
||||
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 $(
|
||||
amixer sget Headphone |
|
||||
grep -oE '([0-9]+)%' |
|
||||
tr -d ' %' |
|
||||
awk '{ s += $1; c++ } END { print s/c }' |
|
||||
xargs printf %.0f
|
||||
)"
|
14
scripts/core/sxmo_xinit.sh
Executable file
14
scripts/core/sxmo_xinit.sh
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env sh
|
||||
source /etc/profile
|
||||
which $TERM || export TERM=st
|
||||
which $BROWSER || export BROWSER=surf
|
||||
|
||||
xsetroot -mod 3 2 -fg '#000000' -bg '#888888'
|
||||
conky -c /usr/share/sxmo/conky.conf -d
|
||||
|
||||
lisgd &
|
||||
sxmo_statusbar.sh &
|
||||
xset s off -dpms
|
||||
#xset r off
|
||||
alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore
|
||||
exec dbus-run-session dwm 2> ~/.dwm.log
|
Loading…
Add table
Add a link
Reference in a new issue