changes again
This commit is contained in:
parent
94d2955ab0
commit
f4b88690f7
12 changed files with 94 additions and 70 deletions
3
.local/bin/scripts/dmenu-askpass
Executable file
3
.local/bin/scripts/dmenu-askpass
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
dmenu -p "$1" -nf '#232323' <&-
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
dmenu -p "$1" -nf '#3a3a3a' <&-
|
|
@ -1,21 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
API_ENDPOINT="http://ip-api.com/json/$1"'?fields=7876383'
|
||||
API_ENDPOINT="http://ip-api.com/json/$1"'?fields='
|
||||
FIELDS_FULL='7876383'
|
||||
FIELDS_SHORT='8192'
|
||||
|
||||
get_stats() {
|
||||
api_response=$(curl "${API_ENDPOINT}" 2>/dev/null)
|
||||
ip=$(jq -r .query <<<"$api_response")
|
||||
ptr="$(dig -x "$ip" | grep -A 1 'ANSWER SECTION' | grep -v 'ANSWER SECTION')"
|
||||
jq -r '[ "IP: \(.query)", "Country: \(.country)", "City: \(.city)", "ISP: \(.isp)", "ASN: \(.as)" ][] | "\(.)"' <<<"$api_response"
|
||||
[ -n "$ptr" ] && echo "PTR: $ptr"
|
||||
api_response=$(curl "${API_ENDPOINT}${FIELDS_FULL}" 2>/dev/null)
|
||||
ip=$(jq -r .query <<< "$api_response")
|
||||
jq -r '[ "IP: \(.query)", "Country: \(.country)", "City: \(.city)", "ISP: \(.isp)", "ASN: \(.as)" ][] | "\(.)"' <<< "$api_response"
|
||||
dig_ans="$(dig -x $ip)"
|
||||
ans_count="$(echo "$dig_ans" | grep -o 'ANSWER: [[:digit:]]\+' | cut -d ' ' -f2)"
|
||||
[ "$ans_count" -gt 0 ] && {
|
||||
printf "PTR: "
|
||||
echo "$(echo "$dig_ans" | grep -A1 ';; ANSWER SECTION' | tail -n1 | awk -F 'PTR' '{ print($2) }' | cut -d $'\t' -f 2)"
|
||||
}
|
||||
}
|
||||
|
||||
if [ -t 0 ] && [ -t 1 ]; then
|
||||
get_stats
|
||||
elif [ -t 1 ]; then
|
||||
notify-send -i /dev/null "Your IP address" "$(get_stats)"
|
||||
notify-send -i /dev/null "" "$(get_stats)"
|
||||
else
|
||||
curl -s ip.me
|
||||
curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query
|
||||
fi
|
||||
|
||||
# vim: ft=bash
|
||||
|
|
|
@ -34,9 +34,9 @@ main() {
|
|||
"--template=${HOME}/.local/share/default.html"
|
||||
"--variable=published_time=$(date -Iseconds -d"$(stat "$1" | grep 'Birth:' | sed 's/.*Birth:\s//')")"
|
||||
)
|
||||
pandoc "${pandoc_options[@]}" <(shift_header "$1") > "$FILENAME" 2>/dev/null &&
|
||||
pandoc "${pandoc_options[@]}" <(shift_header "$1") > "$FILENAME" &&
|
||||
echo "$FILENAME" &&
|
||||
firefox "$FILENAME" 2>/dev/null & disown
|
||||
firefox "$FILENAME" & disown
|
||||
|
||||
sleep 5
|
||||
cleanup
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
#!/bin/bash
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
die() {
|
||||
echo "exitting..."
|
||||
rm -f $PIPE
|
||||
exit 0
|
||||
}
|
||||
|
||||
trap 'die' SIGTERM SIGQUIT SIGINT
|
||||
|
||||
PIPE="/var/run/vpnd.sock"
|
||||
oc_pid=
|
||||
|
||||
[ -p $PIPE ] && exit 1
|
||||
[ "$(id -u)" != "0" ] && exit 1
|
||||
|
||||
trap 'die' SIGTERM SIGQUIT SIGINT
|
||||
|
||||
declare -a CONFIGS
|
||||
for config in /etc/wireguard/*; do
|
||||
for config in /etc/openconnect/config_*; do
|
||||
config="$(basename "$config")"
|
||||
CONFIGS+=("${config%.conf}")
|
||||
CONFIGS+=("${config#config_}")
|
||||
done
|
||||
|
||||
COMMANDS=("up" "down")
|
||||
|
||||
die() {
|
||||
rm $PIPE
|
||||
exit 0
|
||||
}
|
||||
|
||||
in_arr() {
|
||||
declare -n arr="$2"
|
||||
|
||||
|
@ -30,6 +32,19 @@ in_arr() {
|
|||
return 1
|
||||
}
|
||||
|
||||
down() {
|
||||
[ -z "$oc_pid" ] && return
|
||||
kill -s TERM $oc_pid
|
||||
wait $oc_pid
|
||||
oc_pid=
|
||||
}
|
||||
|
||||
up() {
|
||||
[ -n "$oc_pid" ] && down
|
||||
openconnect --config "/etc/openconnect/config_$1" &
|
||||
oc_pid="$!"
|
||||
}
|
||||
|
||||
main() {
|
||||
mkfifo $PIPE -m666
|
||||
|
||||
|
@ -41,7 +56,10 @@ main() {
|
|||
elif ! in_arr "$cmd" "COMMANDS"; then
|
||||
echo "ERROR: Invalid command $cmd" > $PIPE
|
||||
else
|
||||
wg-quick "$cmd" "$ifname" > $PIPE 2>&1
|
||||
case "$cmd" in
|
||||
"up") up "$ifname" > $PIPE ;;
|
||||
"down") down > $PIPE ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
1
.local/share/gnupg/gpg-agent.conf
Normal file
1
.local/share/gnupg/gpg-agent.conf
Normal file
|
@ -0,0 +1 @@
|
|||
pinentry-program /usr/bin/pinentry-curses
|
Loading…
Add table
Add a link
Reference in a new issue