From e23f439b65f51f20bfc85ae09f6af3b5e51e6962 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sat, 6 Jun 2020 23:29:24 -0500 Subject: [PATCH] Minor style cleanups in userscripts implementation --- scripts/core/sxmo_appmenu.sh | 76 +++++++++++++++++++++--------------- scripts/core/sxmo_xinit.sh | 35 +++++++++++------ 2 files changed, 67 insertions(+), 44 deletions(-) diff --git a/scripts/core/sxmo_appmenu.sh b/scripts/core/sxmo_appmenu.sh index aa102eb..28494eb 100755 --- a/scripts/core/sxmo_appmenu.sh +++ b/scripts/core/sxmo_appmenu.sh @@ -7,25 +7,40 @@ programchoicesinit() { # Default system menu (no matches) CHOICES="$(echo " - Scripts ^ 0 ^ sxmo_appmenu.sh scripts - Apps ^ 0 ^ sxmo_appmenu.sh applications - $([ -d $XDG_CONFIG_HOME/sxmo/userscripts ] && [ -n "$(ls -A $XDG_CONFIG_HOME/sxmo/userscripts)" ] && echo 'Userscripts ^ 0 ^ sxmo_appmenu.sh userscripts') - Volume ↑ ^ 1 ^ sxmo_vol.sh up - Volume ↓ ^ 1 ^ sxmo_vol.sh down - Dialer ^ 0 ^ sxmo_modemcall.sh dial - Texts ^ 0 ^ sxmo_modemtext.sh - Camera ^ 0 ^ sxmo_camera.sh - Wifi ^ 0 ^ st -e "nmtui" - Audio ^ 0 ^ sxmo_appmenu.sh audioout - Config ^ 0 ^ sxmo_appmenu.sh config - Logout ^ 0 ^ pkill -9 dwm + $( + [ -n "$(ls -A $XDG_CONFIG_HOME/sxmo/userscripts)" ] && + echo 'Userscripts ^ 0 ^ sxmo_appmenu.sh userscripts' + ) + 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 ^ 0 ^ sxmo_modemcall.sh dial + Texts ^ 0 ^ sxmo_modemtext.sh + Camera ^ 0 ^ sxmo_camera.sh + Wifi ^ 0 ^ st -e "nmtui" + Audio ^ 0 ^ sxmo_appmenu.sh audioout + Config ^ 0 ^ sxmo_appmenu.sh config + Logout ^ 0 ^ pkill -9 dwm ")" && WINNAME=Sys # Userscripts menu - echo $WMCLASS | grep -i "userscripts" && - CHOICES="$(ls -1 $XDG_CONFIG_HOME/sxmo/userscripts | sed 's/ /\\ /' | - awk '{printf "%s\t^ 0 ^ sh $XDG_CONFIG_HOME/sxmo/userscripts/%s \n", $0, $0}')" && - WINNAME=Userscripts && return + echo $WMCLASS | grep -i "userscripts" && CHOICES="$( + ls -1 $XDG_CONFIG_HOME/sxmo/userscripts | + sed 's/ /\\ /' | + awk '{printf "%s\t^ 0 ^ sh $XDG_CONFIG_HOME/sxmo/userscripts/%s \n", $0, $0}' + )" && WINNAME=Userscripts && return + + # Scripts menu + echo $WMCLASS | grep -i "scripts" && CHOICES="$(echo " + Web Search ^ 0 ^ sxmo_websearch.sh + Files ^ 0 ^ sxmo_files.sh + Timer ^ 0 ^ sxmo_timer.sh + Youtube ^ 0 ^ sxmo_youtube.sh video + Youtube (Audio) ^ 0 ^ sxmo_youtube.sh audio + Weather ^ 0 ^ sxmo_weather.sh + RSS ^ 0 ^ sxmo_rss.sh + ")" && WINNAME=Scripts && return # Apps menu echo $WMCLASS | grep -i "applications" && CHOICES="$(echo " @@ -39,17 +54,6 @@ programchoicesinit() { Foxtrotgps ^ 0 ^ foxtrotgps ")" && WINNAME=Apps && return - # Scripts menu - echo $WMCLASS | grep -i "scripts" && CHOICES="$(echo " - Web Search ^ 0 ^ sxmo_websearch.sh - Files ^ 0 ^ sxmo_files.sh - Timer ^ 0 ^ sxmo_timer.sh - Youtube ^ 0 ^ sxmo_youtube.sh video - Youtube (Audio) ^ 0 ^ sxmo_youtube.sh audio - Weather ^ 0 ^ sxmo_weather.sh - RSS ^ 0 ^ sxmo_rss.sh - ")" && WINNAME=Scripts && return - # System Control menu echo $WMCLASS | grep -i "config" && CHOICES="$(echo " Brightesss ↑ ^ 1 ^ sxmo_brightness.sh up @@ -57,7 +61,12 @@ programchoicesinit() { Modem Toggle ^ 1 ^ sxmo_modemmonitortoggle.sh Modem Info ^ 0 ^ sxmo_modeminfo.sh Modem Log ^ 0 ^ sxmo_modemlog.sh - Flash $(cat /sys/class/leds/white:flash/brightness | grep -E '^0$' > /dev/null && echo -n "Off → On" || echo -n "On → Off") ^ 1 ^ sxmo_flashtoggle.sh + Flash $( + cat /sys/class/leds/white:flash/brightness | + grep -E '^0$' > /dev/null && + echo -n "Off → On" || echo -n "On → Off"; + echo -n "^ 1 ^ sxmo_flashtoggle.sh" + ) Bar Toggle ^ 1 ^ key Alt+b Change Timezone ^ 1 ^ sxmo_timezonechange.sh Rotate ^ 1 ^ sxmo_rotate.sh @@ -67,9 +76,9 @@ programchoicesinit() { # Audio Out menu echo $WMCLASS | grep -i "audioout" && CURRENTDEV="$(sxmo_audiocurrentdevice.sh)" && CHOICES="$(echo " Headphones $([[ "$CURRENTDEV" == "Headphone" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Headphones - Speaker $([[ "$CURRENTDEV" == "Line Out" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Speaker - Earpiece $([[ "$CURRENTDEV" == "Earpiece" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Earpiece - None $([[ "$CURRENTDEV" == "None" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh None + Speaker $([[ "$CURRENTDEV" == "Line Out" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Speaker + Earpiece $([[ "$CURRENTDEV" == "Earpiece" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Earpiece + None $([[ "$CURRENTDEV" == "None" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh None ")" && WINNAME="Audio" && return # MPV @@ -91,7 +100,10 @@ programchoicesinit() { echo $WMCLASS | grep -i "st-256color" && STSELMODEON="$(echo "$XPROPOUT" | grep -E '^_ST_SELMODE.+=' | cut -d= -f2 | tr -d ' ')" && CHOICES="$(echo " Type complete ^ 0 ^ key Ctrl+Shift+u Copy complete ^ 0 ^ key Ctrl+Shift+i - Selmode $([ $STSELMODEON == 1 ] && echo 'On → Off' || echo 'Off → On') ^ 0 ^ key Ctrl+Shift+s + Selmode $( + [ $STSELMODEON == 1 ] && printf %b 'On → Off' || printf %b 'Off → On'; + printf %b '^ 0 ^ key Ctrl+Shift+s' + ) $([ $STSELMODEON == 1 ] && echo 'Copy selection ^ 0 ^ key Ctrl+Shift+c') Paste ^ 0 ^ key Ctrl+Shift+v Zoom + ^ 1 ^ key Ctrl+Shift+Prior diff --git a/scripts/core/sxmo_xinit.sh b/scripts/core/sxmo_xinit.sh index 1118411..43b5681 100755 --- a/scripts/core/sxmo_xinit.sh +++ b/scripts/core/sxmo_xinit.sh @@ -1,28 +1,39 @@ #!/usr/bin/env sh +# Env vars source /etc/profile which $TERM || export TERM=st which $BROWSER || export BROWSER=surf [ -z "$MOZ_USE_XINPUT2" ] && export MOZ_USE_XINPUT2=1 [ -z "$XDG_CONFIG_HOME" ] && export XDG_CONFIG_HOME=~/.config +# Setup audio and a few sensible X defaults +alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore xmodmap /usr/share/sxmo/xmodmap_caps_esc xsetroot -mod 3 2 -fg '#000000' -bg '#888888' xset s off -dpms -alsactl --file /usr/share/sxmo/default_alsa_sound.conf restore -#xset r off - -# Xresources xrdb /usr/share/sxmo/xresources_xcalc.xr - -# E.g. for PBP synclient TapButton1=1 TapButton2=3 TapButton3=2 MinSpeed=0.25 -keynav & -pkill lisgd +# Kill old hanging daemons +pkill lisgd && pkill conky +# Start daemons conky -c /usr/share/sxmo/conky.conf -d -autocutsel & autocutsel -selection PRIMARY & +keynav & +autocutsel & +autocutsel -selection PRIMARY & sxmo_statusbar.sh & -exec dbus-run-session sh -c "dunst -conf /usr/share/sxmo/dunst.conf & lisgd & -[ -d "~/.sxmo" ] && notify-send -t 0 -u critical '~/.sxmo is deprecated. To preserve your modem logs, please move the contents of the ~/.sxmo folder into the $XDG_CONFIG_HOME/sxmo/modem/ folder' & -dwm 2> ~/.dwm.log" + +# Start dunst, lisgd (after dunst so it's in dbus path) and dwm +LEGACYSXMOFOLDERWARNING=" +Warning: ~/.sxmo is deprecated since sxmo-utils 1.1.5. +Modem call logs/texts location have moved. +Please move the contents of the ~/.sxmo/ folder to $XDG_CONFIG_HOME/sxmo/modem/ +" + +exec dbus-run-session sh -c " + dunst -conf /usr/share/sxmo/dunst.conf & + lisgd & + [ -d "/home/$USER/.sxmo" ] && notify-send -t 0 -u critical '$LEGACYSXMOFOLDERWARNING' & + dwm 2> ~/.dwm.log +"