From 8ae9fbdb1ce774c41dd193d0b2d5d166675461e6 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sun, 15 Mar 2020 18:42:35 -0500 Subject: [PATCH] Initial commit --- .gitignore | 1 + Makefile | 22 ++ configs/conky.conf | 36 ++ configs/default_alsa_sound.conf | 632 +++++++++++++++++++++++++++++++ configs/sxmo_welcome.html | 1 + programs/sxmo_setpinebacklight.c | 37 ++ programs/sxmo_setpineled.c | 45 +++ scripts/sxmo_appmenu.sh | 138 +++++++ scripts/sxmo_blinkled.sh | 4 + scripts/sxmo_brightness.sh | 25 ++ scripts/sxmo_command.sh | 33 ++ scripts/sxmo_dmenu_with_kb.sh | 6 + scripts/sxmo_edit_screen.sh | 5 + scripts/sxmo_keyboard.sh | 30 ++ scripts/sxmo_lowpowermode.sh | 18 + scripts/sxmo_moveresize.sh | 15 + scripts/sxmo_notify.sh | 12 + scripts/sxmo_pastecomplete.sh | 16 + scripts/sxmo_statusbar.sh | 28 ++ scripts/sxmo_surf_linkselect.sh | 76 ++++ scripts/sxmo_urlhandler.sh | 42 ++ scripts/sxmo_vol.sh | 12 + scripts/sxmo_xinit.sh | 12 + 23 files changed, 1246 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 configs/conky.conf create mode 100644 configs/default_alsa_sound.conf create mode 100644 configs/sxmo_welcome.html create mode 100644 programs/sxmo_setpinebacklight.c create mode 100644 programs/sxmo_setpineled.c create mode 100755 scripts/sxmo_appmenu.sh create mode 100755 scripts/sxmo_blinkled.sh create mode 100755 scripts/sxmo_brightness.sh create mode 100755 scripts/sxmo_command.sh create mode 100755 scripts/sxmo_dmenu_with_kb.sh create mode 100755 scripts/sxmo_edit_screen.sh create mode 100755 scripts/sxmo_keyboard.sh create mode 100755 scripts/sxmo_lowpowermode.sh create mode 100755 scripts/sxmo_moveresize.sh create mode 100755 scripts/sxmo_notify.sh create mode 100755 scripts/sxmo_pastecomplete.sh create mode 100755 scripts/sxmo_statusbar.sh create mode 100755 scripts/sxmo_surf_linkselect.sh create mode 100755 scripts/sxmo_urlhandler.sh create mode 100755 scripts/sxmo_vol.sh create mode 100755 scripts/sxmo_xinit.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3aac5c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +programs/sxmo_setpineled \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b57169b --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +PREFIX:=/usr + +programs/sxmo_setpineled: + gcc -o programs/sxmo_setpineled programs/sxmo_setpineled.c + +programs/sxmo_setpinebacklight: + gcc -o programs/sxmo_setpinebacklight programs/sxmo_setpinebacklight.c + +install: programs/sxmo_setpineled programs/sxmo_setpinebacklight + mkdir -p $(PREFIX)/share/sxmo + cp configs/* $(PREFIX)/share/sxmo + + mkdir -p $(PREFIX)/bin + cp scripts/* $(PREFIX)/bin + + chown root programs/sxmo_setpineled + chmod u+s programs/sxmo_setpineled + cp programs/sxmo_setpineled $(PREFIX)/bin + + chown root programs/sxmo_setpinebacklight + chmod u+s programs/sxmo_setpinebacklight + cp programs/sxmo_setpinebacklight $(PREFIX)/bin diff --git a/configs/conky.conf b/configs/conky.conf new file mode 100644 index 0000000..6d31438 --- /dev/null +++ b/configs/conky.conf @@ -0,0 +1,36 @@ +conky.config = { + alignment = 'middle_middle', + background = false, + border_width = 0.5, + cpu_avg_samples = 4, + default_color = 'white', + default_outline_color = 'grey', + default_shade_color = 'black', + draw_borders = true, + draw_graph_borders = true, + draw_outline = false, + draw_shades = true, + use_xft = true, + font = 'DejaVu Sans Mono:size=10', + gap_x = 5, + gap_y = 50, + minimum_height = 5, + minimum_width = 5, + net_avg_samples = 2, + double_buffer = true, + out_to_console = false, + out_to_stderr = false, + extra_newline = false, + own_window = false, + stippled_borders = 1, + update_interval = 60, + uppercase = false, + use_spacer = 'none', + show_graph_scale = false, + show_graph_range = false +} + +conky.text = [[ + ${font Latin Modern Mono Caps:size=80}${alignc}${exec date +"%I:%M"}${font Latin Modern Mono Caps:size=30}PM + ${font Latin Modern Mono Caps:size=20}${alignc}${exec date +"%b %d, %Y"} +]] diff --git a/configs/default_alsa_sound.conf b/configs/default_alsa_sound.conf new file mode 100644 index 0000000..bbdefc6 --- /dev/null +++ b/configs/default_alsa_sound.conf @@ -0,0 +1,632 @@ +state.sun50ia64audio { + control.1 { + iface MIXER + name 'AIF1 AD0 Capture Volume' + value.0 165 + value.1 165 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 192' + dbmin -9999999 + dbmax 2400 + dbvalue.0 375 + dbvalue.1 375 + } + } + control.2 { + iface MIXER + name 'AIF1 DA0 Playback Volume' + value.0 149 + value.1 149 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 192' + dbmin -9999999 + dbmax 2400 + dbvalue.0 -825 + dbvalue.1 -825 + } + } + control.3 { + iface MIXER + name 'AIF2 ADC Capture Volume' + value.0 168 + value.1 168 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 192' + dbmin -9999999 + dbmax 2400 + dbvalue.0 600 + dbvalue.1 600 + } + } + control.4 { + iface MIXER + name 'AIF2 DAC Playback Volume' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 192' + dbmin -9999999 + dbmax 2400 + dbvalue.0 -9999999 + dbvalue.1 -9999999 + } + } + control.5 { + iface MIXER + name 'ADC Capture Volume' + value.0 179 + value.1 179 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 192' + dbmin -9999999 + dbmax 2400 + dbvalue.0 1425 + dbvalue.1 1425 + } + } + control.6 { + iface MIXER + name 'DAC Playback Volume' + value.0 169 + value.1 169 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 192' + dbmin -9999999 + dbmax 2400 + dbvalue.0 675 + dbvalue.1 675 + } + } + control.7 { + iface MIXER + name 'Headphone Playback Volume' + value 29 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 63' + dbmin -9999999 + dbmax 0 + dbvalue.0 -3400 + } + } + control.8 { + iface MIXER + name 'Mic1 Playback Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + dbmin -450 + dbmax 600 + dbvalue.0 -450 + } + } + control.9 { + iface MIXER + name 'Mic1 Boost Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + dbmin 0 + dbmax 4200 + dbvalue.0 0 + } + } + control.10 { + iface MIXER + name 'Mic2 Playback Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + dbmin -450 + dbmax 600 + dbvalue.0 -450 + } + } + control.11 { + iface MIXER + name 'Mic2 Boost Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + dbmin 0 + dbmax 4200 + dbvalue.0 0 + } + } + control.12 { + iface MIXER + name 'ADC Gain Capture Volume' + value 3 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + dbmin -450 + dbmax 600 + dbvalue.0 0 + } + } + control.13 { + iface MIXER + name 'Line In Playback Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 7' + dbmin -450 + dbmax 600 + dbvalue.0 -450 + } + } + control.14 { + iface MIXER + name 'Line Out Playback Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 31' + dbmin -9999999 + dbmax 0 + dbvalue.0 -9999999 + } + } + control.15 { + iface MIXER + name 'Earpiece Playback Volume' + value 0 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 31' + dbmin -9999999 + dbmax 0 + dbvalue.0 -9999999 + } + } + control.16 { + iface MIXER + name 'AIF1 Loopback Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.17 { + iface MIXER + name 'AIF2 Loopback Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.18 { + iface MIXER + name 'AIF3 Loopback Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'AIF1 AD0 Stereo Capture Route' + value.0 'Mix Mono' + value.1 'Mix Mono' + comment { + access 'read write' + type ENUMERATED + count 2 + item.0 Stereo + item.1 'Reverse Stereo' + item.2 'Sum Mono' + item.3 'Mix Mono' + } + } + control.20 { + iface MIXER + name 'AIF2 ADC Stereo Capture Route' + value.0 Stereo + value.1 Stereo + comment { + access 'read write' + type ENUMERATED + count 2 + item.0 Stereo + item.1 'Reverse Stereo' + item.2 'Sum Mono' + item.3 'Mix Mono' + } + } + control.21 { + iface MIXER + name 'AIF3 ADC Capture Route' + value 'AIF2 Right' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 None + item.1 'AIF2 Left' + item.2 'AIF2 Right' + } + } + control.22 { + iface MIXER + name 'AIF1 AD0 Mixer AIF1 DA0 Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.23 { + iface MIXER + name 'AIF1 AD0 Mixer AIF2 DAC Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.24 { + iface MIXER + name 'AIF1 AD0 Mixer ADC Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.25 { + iface MIXER + name 'AIF1 AD0 Mixer AIF2 DAC Rev Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.26 { + iface MIXER + name 'AIF2 ADC Mixer AIF1 DA0 Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.27 { + iface MIXER + name 'AIF2 ADC Mixer AIF2 DAC Rev Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.28 { + iface MIXER + name 'AIF2 ADC Mixer ADC Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.29 { + iface MIXER + name 'AIF3 DAC Playback Route' + value None + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 None + item.1 'AIF2 Left' + item.2 'AIF2 Right' + } + } + control.30 { + iface MIXER + name 'AIF1 DA0 Stereo Playback Route' + value.0 Stereo + value.1 Stereo + comment { + access 'read write' + type ENUMERATED + count 2 + item.0 Stereo + item.1 'Reverse Stereo' + item.2 'Sum Mono' + item.3 'Mix Mono' + } + } + control.31 { + iface MIXER + name 'AIF2 DAC Stereo Playback Route' + value.0 Stereo + value.1 Stereo + comment { + access 'read write' + type ENUMERATED + count 2 + item.0 Stereo + item.1 'Reverse Stereo' + item.2 'Sum Mono' + item.3 'Mix Mono' + } + } + control.32 { + iface MIXER + name 'DAC Mixer AIF1 DA0 Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.33 { + iface MIXER + name 'DAC Mixer AIF2 DAC Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.34 { + iface MIXER + name 'DAC Mixer ADC Playback Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.35 { + iface MIXER + name 'Headphone Source Playback Route' + value.0 DAC + value.1 DAC + comment { + access 'read write' + type ENUMERATED + count 2 + item.0 DAC + item.1 Mixer + } + } + control.36 { + iface MIXER + name 'Headphone Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.37 { + iface MIXER + name 'Line Out Source Playback Route' + value.0 Stereo + value.1 Stereo + comment { + access 'read write' + type ENUMERATED + count 2 + item.0 Stereo + item.1 'Mono Differential' + } + } + control.38 { + iface MIXER + name 'Line Out Playback Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.39 { + iface MIXER + name 'Earpiece Source Playback Route' + value DACR + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DACR + item.1 DACL + item.2 'Right Mixer' + item.3 'Left Mixer' + } + } + control.40 { + iface MIXER + name 'Earpiece Playback Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.41 { + iface MIXER + name 'Mic1 Playback Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.42 { + iface MIXER + name 'Mic2 Playback Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.43 { + iface MIXER + name 'Line In Playback Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.44 { + iface MIXER + name 'DAC Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.45 { + iface MIXER + name 'DAC Reversed Playback Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.46 { + iface MIXER + name 'Mic1 Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.47 { + iface MIXER + name 'Mic2 Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.48 { + iface MIXER + name 'Line In Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.49 { + iface MIXER + name 'Mixer Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.50 { + iface MIXER + name 'Mixer Reversed Capture Switch' + value.0 false + value.1 false + comment { + access 'read write' + type BOOLEAN + count 2 + } + } +} diff --git a/configs/sxmo_welcome.html b/configs/sxmo_welcome.html new file mode 100644 index 0000000..0766237 --- /dev/null +++ b/configs/sxmo_welcome.html @@ -0,0 +1 @@ +Welcome to sxmo \ No newline at end of file diff --git a/programs/sxmo_setpinebacklight.c b/programs/sxmo_setpinebacklight.c new file mode 100644 index 0000000..703fe58 --- /dev/null +++ b/programs/sxmo_setpinebacklight.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +void usage() { + fprintf(stderr, "Usage: setpinebacklight [0-10]\n"); +} + +int main(int argc, char *argv[]) { + char * command; + int brightness; + + if (argc < 2) { + usage(); + return 1; + } + argc--; + brightness = atoi(argv[argc--]); + + if (brightness < 0 || brightness > 10) { + usage(); + return 1; + } + + command = malloc(100); + sprintf( + command, + "sh -c 'echo %d > /sys/devices/platform/backlight/backlight/backlight/brightness'", + brightness + ); + if (setuid(0)) { + fprintf(stderr, "setuid(0) failed\n"); + } else { + return system(command); + } +} diff --git a/programs/sxmo_setpineled.c b/programs/sxmo_setpineled.c new file mode 100644 index 0000000..dfb0e78 --- /dev/null +++ b/programs/sxmo_setpineled.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +void usage() { + fprintf(stderr, "Usage: setpineled [red|green|blue] [0-255]\n"); +} + +int main(int argc, char *argv[]) { + int brightness; + char * color; + char * command; + + if (argc < 2) { + usage(); + return 1; + } + argc--; + brightness = atoi(argv[argc--]); + + if (brightness < 0 || brightness > 255) { + usage(); + return 1; + } + + color = argv[argc--]; + if (strcmp(color, "red") && strcmp(color, "blue") && strcmp(color, "green")) { + usage(); + return 1; + } + + command = malloc(80); + sprintf( + command, + "sh -c 'echo %d > /sys/devices/platform/leds/leds/pinephone:%s:user/brightness'", + brightness, + color + ); + if (setuid(0)) { + fprintf(stderr, "setuid(0) failed\n"); + } else { + return system(command); + } +} diff --git a/scripts/sxmo_appmenu.sh b/scripts/sxmo_appmenu.sh new file mode 100755 index 0000000..329b541 --- /dev/null +++ b/scripts/sxmo_appmenu.sh @@ -0,0 +1,138 @@ +#!/usr/bin/env sh +WIN=$(xdotool getwindowfocus) + +programchoicesinit() { + WMCLASS="${1:-$(xprop -id $(xdotool getactivewindow) | grep WM_CLASS | cut -d ' ' -f3-)}" + + # Default + CHOICES="$(echo " + Push window tag → ^ 0 ^ sxmo_lowpowermode.sh + Tag focus → ^ 0 ^ sxmo_lowpowermode.sh + Applications ^ 0 ^ sxmo_appmenu.sh applications + Volume ↑ ^ 1 ^ sxmo_vol.sh up + Volume ↓ ^ 1 ^ sxmo_vol.sh down + Brightesss ↑ ^ 1 ^ sxmo_brightness.sh up + Brightness ↓ ^ 1 ^ sxmo_brightness.sh down + Wifi ^ 0 ^ st -e "nmtui" + Rotate ^ 1 ^ rotate + Logout ^ 0 ^ pkill -9 dwm + Close Menu ^ 0 ^ quit + ")" && WINNAME=sys + + echo $WMCLASS | grep -i "applications" && CHOICES="$(echo " + Surf ^ 0 ^ surf + NetSurf ^ 0 ^ netsurf + St ^ 0 ^ st + Firefox ^ 0 ^ firefox + Foxtrotgps ^ 0 ^ foxtrotgps + Close Menu ^ 0 ^ quit + ")" && WINNAME=Apps + + + echo $WMCLASS | grep -i "mpv" && CHOICES="$(echo " + Pause ^ 0 ^ key space + ")" && 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 + 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- ^ 0 ^ key Ctrl+L + 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() { + xset r off + exit 0 +} + +boot() { + DMENUIDX=0 + PICKED="" + xset r on + 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 10 -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 diff --git a/scripts/sxmo_blinkled.sh b/scripts/sxmo_blinkled.sh new file mode 100755 index 0000000..fed4add --- /dev/null +++ b/scripts/sxmo_blinkled.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +sxmo_setpineled $1 150 +sleep 0.01 +sxmo_setpineled $1 0 diff --git a/scripts/sxmo_brightness.sh b/scripts/sxmo_brightness.sh new file mode 100755 index 0000000..963bf11 --- /dev/null +++ b/scripts/sxmo_brightness.sh @@ -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 \ No newline at end of file diff --git a/scripts/sxmo_command.sh b/scripts/sxmo_command.sh new file mode 100755 index 0000000..93cfbf5 --- /dev/null +++ b/scripts/sxmo_command.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +power_1() { + pgrep -f sxmo_appmenu.sh || sxmo_keyboard.sh +} +power_2() { + st +} +power_3() { + surf +} + +voldown_1() { + pgrep -f sxmo_appmenu.sh && xdotool key Control+n || xdotool key Alt+Ctrl+period +} +voldown_2() { + xdotool key Alt+Shift+c +} +voldown_3() { + xdotool key Alt+Return +} + +volup_1() { + pgrep -f sxmo_appmenu.sh && xdotool key Control+p || sxmo_appmenu.sh +} +volup_2() { + echo nop +} +volup_3() { + echo nop +} + +$@ diff --git a/scripts/sxmo_dmenu_with_kb.sh b/scripts/sxmo_dmenu_with_kb.sh new file mode 100755 index 0000000..a95f235 --- /dev/null +++ b/scripts/sxmo_dmenu_with_kb.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +sxmo_keyboard.sh on & +OUTPUT="$(cat | dmenu -t $@)" +sxmo_keyboard.sh off +echo "$OUTPUT" diff --git a/scripts/sxmo_edit_screen.sh b/scripts/sxmo_edit_screen.sh new file mode 100755 index 0000000..3326666 --- /dev/null +++ b/scripts/sxmo_edit_screen.sh @@ -0,0 +1,5 @@ +#!/bin/sh +tmpfile=$(mktemp /tmp/st-edit.XXXXXX) +trap 'rm "$tmpfile"' 0 1 15 +cat > "$tmpfile" +st -e "$EDITOR" "$tmpfile" diff --git a/scripts/sxmo_keyboard.sh b/scripts/sxmo_keyboard.sh new file mode 100755 index 0000000..1dfeed7 --- /dev/null +++ b/scripts/sxmo_keyboard.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env sh + +P=/tmp/KEYTOG + +keyoff() { + kill -9 $(cat $P) + pgrep -f sxmo_keyboard.sh | grep -Ev "^${$}$" | xargs kill -9 + pkill -9 svkbd-en + pkill -9 svkbd-symbols + rm $P +} + +keyon() { + echo $$ >> $P + while : + do + svkbd-en -d + svkbd-symbols -d + done +} + +if [ "$1" == "on" ]; then + [ -f $P ] && keyoff + keyon +elif [ "$1" == "off" ]; then + [ -f $P ] && keyoff +else + # Default toggle + [ -f $P ] && keyoff || keyon +fi diff --git a/scripts/sxmo_lowpowermode.sh b/scripts/sxmo_lowpowermode.sh new file mode 100755 index 0000000..c69f8fb --- /dev/null +++ b/scripts/sxmo_lowpowermode.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh +TOUCHSCREENID=$( + xinput | + grep -i touchscreen | + grep pointer | + grep -oE 'id=[0-9]+' | + cut -d= -f2 +) + +xinput disable $TOUCHSCREENID +sxmo_setpineled blue 1 +OLDB="$(cat /sys/class/backlight/backlight/brightness)" +sxmo_setpinebacklight 0 +echo "Dragons?" | dmenu + +sxmo_setpinebacklight $OLDB +sxmo_setpineled blue 0 +xinput enable $TOUCHSCREENID diff --git a/scripts/sxmo_moveresize.sh b/scripts/sxmo_moveresize.sh new file mode 100755 index 0000000..5275d3a --- /dev/null +++ b/scripts/sxmo_moveresize.sh @@ -0,0 +1,15 @@ +move() { + xdotool keydown Alt + echo "Move done?" | dmenu + xdotool keyup Alt +} + +resize() { + xdotool keydown Alt + xdotool mousedown 3 + echo "Resize done?" | dmenu + xdotool keyup Alt + xdotool mouseup 3 +} + +$@ \ No newline at end of file diff --git a/scripts/sxmo_notify.sh b/scripts/sxmo_notify.sh new file mode 100755 index 0000000..4af5203 --- /dev/null +++ b/scripts/sxmo_notify.sh @@ -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" & diff --git a/scripts/sxmo_pastecomplete.sh b/scripts/sxmo_pastecomplete.sh new file mode 100755 index 0000000..157f4e1 --- /dev/null +++ b/scripts/sxmo_pastecomplete.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +sxmo_keyboard.sh on & + +cat |\ +grep -Eo '\\S+' |\ +tr -d '[:blank:]' |\ +sort |\ +uniq |\ +dmenu -p Type -l 10 -i -c -fn Terminus-20 + +sxmo_keyboard.sh off + +if [[ "$RESULT" = "Close Menu" ]]; then +else + xargs -I CC xdotool type "$RESULT" +fi diff --git a/scripts/sxmo_statusbar.sh b/scripts/sxmo_statusbar.sh new file mode 100755 index 0000000..4272913 --- /dev/null +++ b/scripts/sxmo_statusbar.sh @@ -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 \ No newline at end of file diff --git a/scripts/sxmo_surf_linkselect.sh b/scripts/sxmo_surf_linkselect.sh new file mode 100755 index 0000000..de255ad --- /dev/null +++ b/scripts/sxmo_surf_linkselect.sh @@ -0,0 +1,76 @@ +#!/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) +} + +link_select \ No newline at end of file diff --git a/scripts/sxmo_urlhandler.sh b/scripts/sxmo_urlhandler.sh new file mode 100755 index 0000000..6576922 --- /dev/null +++ b/scripts/sxmo_urlhandler.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env sh + +# URL test passed from $1 +URL=${1:-$URL} + +# 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 + +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" diff --git a/scripts/sxmo_vol.sh b/scripts/sxmo_vol.sh new file mode 100755 index 0000000..70853af --- /dev/null +++ b/scripts/sxmo_vol.sh @@ -0,0 +1,12 @@ +#!/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 diff --git a/scripts/sxmo_xinit.sh b/scripts/sxmo_xinit.sh new file mode 100755 index 0000000..88ae7d7 --- /dev/null +++ b/scripts/sxmo_xinit.sh @@ -0,0 +1,12 @@ +#!/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 + +sxmo_statusbar.sh & +xset r off +alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore +exec dbus-run-session dwm 2> ~/.dwm.log