diff --git a/.config/shell/functions b/.config/shell/functions index 46cfc3e..365af5d 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -145,21 +145,6 @@ alias lar='last | tac' # Listen to loopback of mic alias listen='pactl load-module module-loopback; echo "Press Enter to stop"; read; pactl unload-module module-loopback' -alias browse-safe='sudo systemctl disable --now systemd-resolved && sudo rm -f /etc/resolv.conf && echo "nameserver 185.228.168.10" | sudo tee /etc/resolv.conf && sudo chattr +i /etc/resolv.conf' -browse-unsafe() { - echo "Why do you want to browse unsafe?" - while test ${#intention} -lt 10 - do read intention - done - jrnl intentions-nug "$intention" - trap 'echo Browsing safe; browse-safe' INT - sudo chattr -i /etc/resolv.conf && - sudo mv /etc/resolv.conf /etc/resolv.conf.bak && - sudo systemctl enable --now systemd-resolved && - sleep ${1:-100} - browse-safe -} - xo() { while test $# -gt 0; do xdg-open "$1" diff --git a/.local/bin/scripts/browse-safe b/.local/bin/scripts/browse-safe new file mode 100755 index 0000000..d2afd7a --- /dev/null +++ b/.local/bin/scripts/browse-safe @@ -0,0 +1,11 @@ +#!/bin/sh +# Replace systemd-resolved with the Adult Filter DNS of https://cleanbrowsing.org/filters +set -e +sudo systemctl disable --now systemd-resolved +resolvconf="/etc/resolv.conf" +dns="nameserver 185.228.168.10 +nameserver 185.228.169.11" +test "$(cat "$resolvconf" 2>/dev/null)" = "$dns" && exit 0 +test -f "$resolvconf" && sudo chattr -i "$resolvconf" && sudo rm -vf "$resolvconf" +echo "$dns" | sudo tee "$resolvconf" +sudo chattr +i "$resolvconf" diff --git a/.local/bin/scripts/browse-unsafe b/.local/bin/scripts/browse-unsafe new file mode 100755 index 0000000..a1e4222 --- /dev/null +++ b/.local/bin/scripts/browse-unsafe @@ -0,0 +1,15 @@ +#!/bin/sh +# Temporarily disable cleanbrowsing +echo "Why do you want to browse unsafe?" +while test ${#intention} -lt 10 +do read intention +done +jrnl intentions-nug "$intention" +trap 'echo Cancelling unsafe browsing && browse-safe; exit $?' INT +test -f "/etc/resolv.conf" && + sudo chattr -i /etc/resolv.conf && + sudo mv /etc/resolv.conf /etc/resolv.conf.bak +sudo systemctl enable --now systemd-resolved +sleep ${1:-100} +echo "Ending unsafe browsing" +browse-safe