diff --git a/battery-check.sh b/battery-check.sh new file mode 100755 index 0000000..f4f9483 --- /dev/null +++ b/battery-check.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +acpi=$(acpi) + +# Nothing to be done if we are charging +if echo "$acpi" | grep -q Charging; then + exit 0 +fi + +percent=$(echo $acpi | cut -d, -f2 | sed 's/%//') + +if [ $percent -le 10 ]; then + notify-send -u critical "Battery:${percent}%" +elif [ $percent -le 15 ]; then + notify-send -u normal "Battery:${percent}%" +elif [ $percent -le 20 ]; then + notify-send -u low "Battery:${percent}%" +fi diff --git a/ga.sh b/ga.sh new file mode 100755 index 0000000..da6a493 --- /dev/null +++ b/ga.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +for url in \ + https://analytics.google.com/analytics/web/#/report-home/a62285904w148949408p153837579 \ + https://analytics.google.com/analytics/web/#/report-home/a62285904w148936346p153856341 \ + https://analytics.google.com/analytics/web/#/report-home/a62285904w97282594p101425900; do + chromium --new-window ${url} +done diff --git a/install-nicos-notebook b/install-nicos-notebook new file mode 100755 index 0000000..6107ae6 --- /dev/null +++ b/install-nicos-notebook @@ -0,0 +1,55 @@ +#!/bin/sh + +set -x +set -e + +# 1. Create partitions +# 2. install OS +# 3. configure with cdist +# 4. start initial sync (mbsync, nextcloud) + +# Things to automate: +# - mbsync call (?) +# - nextcloud sync / config +# - wireguard installation / config + +# Things to fix: +# cdist sets hostname of HOST when running in chroot! + +if [ $# -ne 1 ]; then + echo "$0 name-of-the-notebook" + exit 1 +fi + +# Get OS + +alpine_version=3.10.2 +alpine_url=http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64/alpine-minirootfs-${alpine_version}-x86_64.tar.gz + +hostname=nicos-notebook + +tmpdir=$(mktemp -d) +tmpdir=/tmp/tmp.w5LTsMtCDX + +root_dir=${tmpdir}/rootfs +dot_cdist=~/vcs/nico-dot-cdist/ +cdist_dir=~/vcs/cdist +cdist_copy=${cdist_dir}/other/examples/remote/chroot/copy +cdist_exec=${cdist_dir}/other/examples/remote/chroot/exec + +cd ${tmpdir} + +# get alpine chroot / extract +wget -c ${alpine_url} -O alpine.tar.gz +mkdir ${root_dir} +chmod 0755 ${root_dir} +cd ${root_dir} +sudo tar xvfz ${tmpdir}/alpine.tar.gz + +# enable networking +sudo cp /etc/resolv.conf ${root_dir}/etc/ +sudo sudo chroot ${root_dir} apk update + +sudo ${cdist_dir}/bin/cdist config -vv -c ${dot_cdist} \ + --remote-copy "${cdist_copy} ${root_dir}" \ + --remote-exec "${cdist_exec} ${root_dir}" ${hostname} diff --git a/mailer b/mailer new file mode 100755 index 0000000..8d75ed9 --- /dev/null +++ b/mailer @@ -0,0 +1,25 @@ +#!/bin/sh + +if [ $# -ne 4 ]; then + echo "$0 subject from bcc-addr addressfile" + echo "f.i. $0 'How are you?' 'Some Body ' 'another@example.com' ./addresses " + echo "Address file format: | Name | Mail |" + exit 1 +fi + +subject=$1; shift +from=$1; shift +bcc=$1; shift +addresses_file=$1; shift + + +while read line; do + name=$(echo $line | awk -F '|' '{ print $2 }' | sed -e 's/^ *//' -e 's/ *$//') + email=$(echo $line | awk -F '|' '{ print $3 }' | sed -e 's/^ *//' -e 's/ *$//') + + sed "s/PERSON/$name/" mail | \ + mail -s "$subject" \ + -r "$from" \ + -b "$bcc" \ + "$name <$email>" +done < "$addresses_file" diff --git a/mainemacs b/mainemacs index 8fb818c..6eaef8f 100755 --- a/mainemacs +++ b/mainemacs @@ -1,2 +1,3 @@ #!/bin/sh -emacs --funcall "mu4e" --name mainemacs +# emacs --funcall "mu4e" --name mainemacs +emacsclient -c -e '(mu4e)' diff --git a/mount-loch b/mount-loch index f76ce9a..becdbab 100755 --- a/mount-loch +++ b/mount-loch @@ -1 +1 @@ -sshfs nutzer@loch:/ ~/.loch +sshfs loch:/ ~/.loch diff --git a/myssh.sh b/myssh.sh new file mode 100755 index 0000000..40177dd --- /dev/null +++ b/myssh.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# SSH for people who did not sleep long enough +# Changes background colour to red for remote and resets to LightYellow2 after +# the session is finished +# +# Inspiration by Stefan Baur +# Coded by Nico Schottelius, 2020-01-19 +# +# Copying: GPLv3 + +printf '\033]10;black\007' +printf '\033]11;red\007' +echo '' +ssh "$@" +printf '\033]11;LightYellow2\007' +printf '\033]10;black\007' +echo '' diff --git a/notebook-stats b/notebook-stats index e91bb40..baa09c0 100755 --- a/notebook-stats +++ b/notebook-stats @@ -3,7 +3,9 @@ exec 2>&1 if [ $# -ge 1 ]; then - printf "Estimated location\n\n$@\n\n" + printf 'Estimated location\n\n' + echo "$@" + printf '\n\n' fi printf 'My IP addresses\n\n' diff --git a/start-post-i3 b/start-post-i3 index f0a6af4..f7d942f 100755 --- a/start-post-i3 +++ b/start-post-i3 @@ -6,9 +6,9 @@ i3-msg 'workspace 2; append_layout ~/.i3/workspace-2.json' i3-msg 'workspace 10' # Start programs afterwards and watch matching -#if command -v firefox; then -# firefox & -if command -v chromium; then +if command -v firefox; then + firefox & +elif command -v chromium; then chromium & elif command -v chromium-browser; then chromium-browser & @@ -19,3 +19,6 @@ if [ -f /etc/arch-release ]; then else ssh-add /dev/null && v6_ok=yes +ping -c3 $v4_addr >/dev/null && v4_ok=yes + +# Now verify/check what is reachable +if [ $v6_ok ]; then + wg-quick up ${tunnel} + wg set wgungleich peer ${publickey} endpoint ${v6_addr}:${port} +elif [ $v4_ok ]; then + wg-quick up ${tunnel} + wg set wgungleich peer ${publickey} endpoint ${v4!_addr}:${port} +else + echo "The endpoint ${endpoint} is unreachable, try again later" >&2 + exit 1 +fi