-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathw3m.sh
executable file
·57 lines (51 loc) · 1.42 KB
/
w3m.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# path: /home/klassiker/.local/share/repos/shell/w3m.sh
# author: klassiker [mrdotx]
# github: https://github.com/mrdotx/shell
# date: 2024-05-04T11:45:10+0200
# help
script=$(basename "$0")
help="$script [-h/--help] -- wrapper script to start w3m
Usage:
$script [--tabbed]
Settings:
[--tabbed] = start w3m in suckless tabbed tool
Examples:
$script
$script suckless.org
$script --tabbed w3m.sourceforge.net suckless.org "
case "$1" in
-h | --help)
printf "%s\n" "$help"
;;
--tabbed)
shift
xidfile="/tmp/w3m/tabbed-w3m.xid"
mkdir -p "/tmp/w3m"
for uri in "${@:-"$WWW_HOME"}"; do
xid=$(cat "$xidfile" 2>/dev/null)
case $? in
0)
if xprop -id "$xid" >/dev/null 2>&1; then
st -w "$xid" -e w3m "$uri" >/dev/null 2>&1 &
else
tabbed -cdn tabbed-w3m -r 2 \
st -w '' -e w3m "$uri" >/dev/null 2>&1 &
fi
;;
*)
tabbed -cdn tabbed-w3m -r 2 \
st -w '' -e w3m "$uri" >"$xidfile" 2>/dev/null &
;;
esac
sleep 1
done
;;
*)
if [ -z "$TMUX" ]; then
$TERMINAL -e w3m "$@" &
else
w3m "$@"
fi
;;
esac