~anjan/public-inbox

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

[PATCH] sxmo_websearch.sh: Modified sxmo_websearch.sh to include functionality for a bookmarks file.

Details
Message ID
<SYBP282MB238247EA34DB7AA986D87A51F7079@SYBP282MB2382.AUSP282.PROD.OUTLOOK.COM>
DKIM signature
missing
Download raw message
Patch: +53 -0
Needs a tsv file located at ~/.config/sxmo/bookmarks.tsv to utilise the
additional functionality

Included example file for reference.

Signed-off-by: hazardchem <pthom44@live.com.au>
---
 scripts/README.md         |  5 +++++
 scripts/bookmarks.tsv     |  1 +
 scripts/sxmo_websearch.sh | 47 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+)
 create mode 100644 scripts/bookmarks.tsv
 create mode 100755 scripts/sxmo_websearch.sh

diff --git a/scripts/README.md b/scripts/README.md
index 203bf87..993952b 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -94,3 +94,8 @@ Copy the script to `$XDG_CONFIG_HOME/sxmo/userscripts` and make it executable.
- Author: Peter Thomason <pthom44@live.com.au> 
- Licence: GPL3+ 
- Description: An script that will save specific env variables in a file for future use. Required by alarm.sh to work properly. 

## sxmo_websearch.sh
- Author: Peter Thomason <pthom44@live.com.au>
- Licence: GPL3+
- Description: Modified sxmo_websearch.sh to have a bookmarks file selection. Default location for bookmarks is ~/.config/sxmo/bookmarks.tsv
diff --git a/scripts/bookmarks.tsv b/scripts/bookmarks.tsv
new file mode 100644
index 0000000..e3b1a4b
--- /dev/null
+++ b/scripts/bookmarks.tsv
@@ -0,0 +1 @@
URL	SXMO	https://sr.ht/~mil/Sxmo/
\ No newline at end of file
diff --git a/scripts/sxmo_websearch.sh b/scripts/sxmo_websearch.sh
new file mode 100755
index 0000000..6b6f144
--- /dev/null
+++ b/scripts/sxmo_websearch.sh
@@ -0,0 +1,47 @@
#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# title="$icon_glb Web Search"
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh

search(){
	if [ -f "$XDG_CONFIG_HOME"/sxmo/bookmarks.tsv ]; then
		SEARCHQUERY="$(echo "Close Menu" | sed 's/^/Bookmarks\n/' | sxmo_dmenu_with_kb.sh -p "Search:")" || exit 0
	else
		SEARCHQUERY="$(echo "Close Menu" | sxmo_dmenu_with_kb.sh -p "Search:")" || exit 0
	fi

	case "$SEARCHQUERY" in
		"Close Menu") exit 0 ;;
		"Bookmarks") bookmarks ;;
		*) $BROWSER "https://duckduckgo.com/?q=${SEARCHQUERY}" ;;
	esac
}

bookmarks(){
	## Web Apps list, use "Type (tab) Name (tab) URL" for list format
	## keeping the " at the end
	WebList=$(cat "$XDG_CONFIG_HOME"/sxmo/bookmarks.tsv)

	## Menu title at top
	Name="Websites"
	Type="$(printf '%s' "$WebList" | cut -f1 | sort -u)"
	
	choice="$(printf '%s' "$Type" | awk '($0){print} END{print "Close Menu"}' | sxmo_dmenu.sh -i -p "$Name")"
	if test "$choice" = "Close Menu"; then
		search
	fi
	list="$(printf '%s' "$WebList" | grep "$choice" | cut -f2 |  awk '($0){print} END{print "Close Menu"}' | sxmo_dmenu.sh -i -p "$choice")"

	case "$list" in
		"Close Menu") bookmarks ;;
		*)
			play="$(printf '%s' "$WebList" | grep "$list" | cut -f3)"
			sxmo_urlhandler.sh "$play" ;;
	esac
}

# Execution
search
\ No newline at end of file
-- 
2.38.1
Details
Message ID
<87fsbk5tv8.fsf@momi.ca>
In-Reply-To
<SYBP282MB238247EA34DB7AA986D87A51F7079@SYBP282MB2382.AUSP282.PROD.OUTLOOK.COM> (view parent)
DKIM signature
missing
Download raw message
Thanks! I have applied. Sorry for the late response.
--
w:] www.momi.ca
pgp:] https://momi.ca/publickey.txt
Reply to thread Export thread (mbox)