-
Notifications
You must be signed in to change notification settings - Fork 0
/
bm.filter.dpi
executable file
·54 lines (47 loc) · 1.42 KB
/
bm.filter.dpi
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
#!/bin/bash
# Copyright (c) 2024 Rodrigo Arias Mallo
# SPDX-License-Identifier: GPL-3.0-or-later
IFS= read -d '>' auth # Ignore auth
IFS= read -d '>' cmd
set -e # Stop on first error
add_bookmark() {
printf "<cmd='chat' msg='Hi browser' '>\n"; IFS= read -d '>' cmd
printf "<cmd='chat' msg='Is it worth it' '>\n"; IFS= read -d '>' cmd
printf "<cmd='chat' msg='Ok, send it' '>\n"; IFS= read -d '>' cmd
case "$cmd" in
"<cmd='add_bookmark' url='"*);;
*) echo $cmd >&2; exit;;
esac
cut=${cmd#"<cmd='add_bookmark' url='"}
url=$(echo "$cut" | sed "s/' title=.*//" | sed "s/''/'/g")
title=$(echo "$cut" | sed "s/.*' title='//;s/' '$//" | sed "s/''/'/g")
ffsclient bookmarks create bookmark "$title" "$url"
printf "<cmd='send_status_message' msg='Bookmark added' '>\n"
exit
}
case "$cmd" in
"<cmd='open_url' url='"*);;
"<cmd='chat' msg='Hi server'"*) add_bookmark;;
*) echo $cmd >&2; exit;;
esac
printf "<cmd='start_send_page' url='' '>\n"
printf "Content-type: text/html\r\n\r\n"
printf "<!DOCTYPE html>\n<html>\n<head>\n"
printf "<title>Bookmarks</title>\n"
printf "<style>\n"
cat << EOF
html {
background-color: white
}
body {
margin: 2em;
font-size: 15px;
line-height: 1.5em;
}
EOF
printf "</style>\n"
printf "</head><body>\n"
ffsclient bookmarks list --format netscape |\
sed 's/<DL>/<UL>/g;s/<DT>/<LI>/g;s_</DL>_</UL>_g;s_</DT>_</LI>_g' |\
awk '/^<TITLE>/ { p=1; next } p { print } { next }'
printf "</body>\n"