~mil/sxmo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH sxmo-utils] Add proximity lock toggle on the config menu

Details
Message ID
<20210413155939.31654-1-contact@stacyharper.net>
DKIM signature
pass
Download raw message
Patch: +40 -4
Signed-off-by: Stacy Harper <contact@stacyharper.net>
---
 scripts/core/sxmo_appmenu.sh             |  4 ++++
 scripts/core/sxmo_proximitylock.sh       | 13 ++++++++++++-
 scripts/core/sxmo_proximitylocktoggle.sh | 18 ++++++++++++++++++
 scripts/modem/sxmo_modemcall.sh          |  9 ++++++---
 4 files changed, 40 insertions(+), 4 deletions(-)
 create mode 100644 scripts/core/sxmo_proximitylocktoggle.sh

This rely on the "Rework the incoming call pickup/discard behavior" patch

diff --git a/scripts/core/sxmo_appmenu.sh b/scripts/core/sxmo_appmenu.sh
index f80b5c4..b2e9ba8 100755
--- a/scripts/core/sxmo_appmenu.sh
+++ b/scripts/core/sxmo_appmenu.sh
@@ -136,6 +136,10 @@ programchoicesinit() {
				pgrep -f "$(command -v sxmo_rotateautotoggle.sh)" > /dev/null &&
				printf %b "On → Off ^ 0 ^ sxmo_rotateautotoggle.sh &" ||  printf %b "Off → On ^ 0 ^ sxmo_rotateautotoggle.sh &"
			)
			$icon_lck Proximity Lock $(
				pgrep -f "$(command -v sxmo_proximitylock.sh)" > /dev/null &&
				printf %b "On → Off ^ 0 ^ sxmo_proximitylocktoggle.sh &" ||  printf %b "Off → On ^ 0 ^ sxmo_proximitylocktoggle.sh &"
			)
			$icon_ror Rotate                     ^ 1 ^ sxmo_rotate.sh rotate
			$icon_upc Upgrade Pkgs               ^ 0 ^ st -e sxmo_upgrade.sh
			$icon_cfg Edit configuration         ^ 0 ^ st -e $EDITOR $XDG_CONFIG_HOME/sxmo/xinit
diff --git a/scripts/core/sxmo_proximitylock.sh b/scripts/core/sxmo_proximitylock.sh
index 3834873..a0505e6 100644
--- a/scripts/core/sxmo_proximitylock.sh
+++ b/scripts/core/sxmo_proximitylock.sh
@@ -1,7 +1,16 @@
#!/usr/bin/env sh

islocked() {
	pgrep -f sxmo_lock.sh > /dev/null
}

syncstate() {
	islocked && STATE=locked || STATE=free
}

finish() {
	kill $(jobs -p)
	syncstate
	[ free = "$STATE" ] && [ true = "$WASLOCKED" ] && sxmo_lock.sh &
	exit 0
}
@@ -18,10 +27,12 @@ TARGET=30
mainloop() {
	while true; do
		distance="$(distance)"
		# here we do not syncstate to allow user manual lock
		if [ locked = "$STATE" ] && [ "$distance" -lt "$TARGET" ]; then
			pkill -f sxmo_lock.sh
			STATE=free
		elif [ free = "$STATE" ] && [ "$distance" -gt "$TARGET" ]; then
			islocked && pkill -f sxmo_lock.sh # we want screen-off on proximity
			sxmo_lock.sh --screen-off &
			STATE=locked
		fi
@@ -29,7 +40,7 @@ mainloop() {
	done
}

pgrep -f sxmo_lock.sh > /dev/null && STATE=locked || STATE=free
syncstate
if [ locked = "$STATE" ]; then
	WASLOCKED=true

diff --git a/scripts/core/sxmo_proximitylocktoggle.sh b/scripts/core/sxmo_proximitylocktoggle.sh
new file mode 100644
index 0000000..c424198
--- /dev/null
+++ b/scripts/core/sxmo_proximitylocktoggle.sh
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

proximitylockdisable() {
	notify-send "Proximity Lock Disabled"
	pkill -f "$(command -v sxmo_proximitylock.sh)"
	exit 0
}

proximitylockenable() {
	notify-send "Proximity Lock Enabled"
	setsid -f sxmo_proximitylock.sh &
}

if pgrep -f "$(command -v sxmo_proximitylock.sh)"; then
	proximitylockdisable
else
	proximitylockenable
fi
diff --git a/scripts/modem/sxmo_modemcall.sh b/scripts/modem/sxmo_modemcall.sh
index fd8e9b9..b5ac6bf 100755
--- a/scripts/modem/sxmo_modemcall.sh
+++ b/scripts/modem/sxmo_modemcall.sh
@@ -25,7 +25,7 @@ finish() {
		echo "sxmo_modemcall: $1">&2
		notify-send "$1"
	fi
	kill $LOCKPID
	[ -n "$LOCKPID" ] && kill $LOCKPID
	pkill -9 dmenu
	exit 1
}
@@ -257,8 +257,11 @@ incomingcallmenu() {

modem_n || finish "Couldn't determine modem number - is modem online?"

sxmo_proximitylock.sh &
LOCKPID="$!"
# do not duplicate proximity lock if already running
if ! pgrep -f sxmo_proximitylock.sh > /dev/null; then
	sxmo_proximitylock.sh &
	LOCKPID="$!"
fi

"$@" &
MAINPID="$!"
-- 
2.31.1

[sxmo-utils/patches/.build.yml] build failed

builds.sr.ht
Details
Message ID
<CAMPYVC8074G.2ZEL2830WC72A@cirno>
In-Reply-To
<20210413155939.31654-1-contact@stacyharper.net> (view parent)
DKIM signature
missing
Download raw message
sxmo-utils/patches/.build.yml: FAILED in 15s

[Add proximity lock toggle on the config menu][0] from [Stacy Harper][1]

[0]: https://lists.sr.ht/~mil/sxmo-devel/patches/22016
[1]: mailto:contact@stacyharper.net

✗ #485075 FAILED sxmo-utils/patches/.build.yml https://builds.sr.ht/~mil/job/485075
Details
Message ID
<20210423172136.nd7ciz4o5e7telje@worker.anaproy.lxd>
In-Reply-To
<20210413155939.31654-1-contact@stacyharper.net> (view parent)
DKIM signature
missing
Download raw message
Thanks, applied!

--

Maarten van Gompel (proycon)
https://proycon.anaproy.nl
Reply to thread Export thread (mbox)