From 0bfe8604aec316671d27863ac0acb18ce5c2edfa Mon Sep 17 00:00:00 2001
From: dadada <dadada@dadada.li>
Date: Sun, 24 Jan 2021 19:00:03 +0100
Subject: [PATCH 1/2] Initial commit

---
 LICENSE             | 21 +++++++++++++++++++++
 bin/archpad         | 24 ++++++++++++++++++++++++
 bin/colortest       | 26 ++++++++++++++++++++++++++
 bin/lock-session    |  6 ++++++
 bin/notify-failed   |  3 +++
 bin/notify-finished |  3 +++
 bin/notify-starting |  3 +++
 bin/share           | 14 ++++++++++++++
 default.nix         | 20 ++++++++++++++++++++
 9 files changed, 120 insertions(+)
 create mode 100644 LICENSE
 create mode 100755 bin/archpad
 create mode 100755 bin/colortest
 create mode 100755 bin/lock-session
 create mode 100755 bin/notify-failed
 create mode 100755 bin/notify-finished
 create mode 100755 bin/notify-starting
 create mode 100755 bin/share
 create mode 100644 default.nix

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6d3d98f
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Tim Schubert
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/bin/archpad b/bin/archpad
new file mode 100755
index 0000000..3cfe4ff
--- /dev/null
+++ b/bin/archpad
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+url="$1"
+pad=$(basename $url).txt
+dst="$2"
+gitdir="$(dirname $dst)"
+
+wget -Q 10m -O "${dst}" "${url}/export/txt"
+status="$?"
+
+if [ ${status} -ne 0 ]; then
+	echo "Failed to get pad at ${url}"
+	return ${status}
+else
+	git -C "${gitdir}" add "${dst}"
+	changes=$(git -C "${gitdir}" diff --cached | wc -l)
+	if [ $changes -gt 0 ]; then
+		git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}"
+	else
+		echo "Nothing changed for ${url}"
+	fi
+fi
+
+git -C "${gitdir}" reset --hard HEAD
diff --git a/bin/colortest b/bin/colortest
new file mode 100755
index 0000000..d5b5a0c
--- /dev/null
+++ b/bin/colortest
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+#
+#   This file echoes a bunch of color codes to the 
+#   terminal to demonstrate what's available.  Each 
+#   line is the color code of one forground color,
+#   out of 17 (default + 16 escapes), followed by a 
+#   test use of that color on all nine background 
+#   colors (default + 8 escapes).
+#
+
+T='gYw'   # The test text
+
+echo -e "\n                 40m     41m     42m     43m\
+     44m     45m     46m     47m";
+
+for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
+           '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
+           '  36m' '1;36m' '  37m' '1;37m';
+  do FG=${FGs// /}
+  echo -en " $FGs \033[$FG  $T  "
+  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
+    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
+  done
+  echo;
+done
+echo
diff --git a/bin/lock-session b/bin/lock-session
new file mode 100755
index 0000000..6225bb5
--- /dev/null
+++ b/bin/lock-session
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.MainWindow.lockAllDatabases
+swaymsg 'output * dpms off'
+swaylock -c 1f2022
+swaymsg 'output * dpms on'
diff --git a/bin/notify-failed b/bin/notify-failed
new file mode 100755
index 0000000..231a476
--- /dev/null
+++ b/bin/notify-failed
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+notify-send -u critical "$1" 'Unit failed' --icon=dialog-warning
diff --git a/bin/notify-finished b/bin/notify-finished
new file mode 100755
index 0000000..7201a77
--- /dev/null
+++ b/bin/notify-finished
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+notify-send -u low "$1" 'Unit finished' --icon=dialog-information
diff --git a/bin/notify-starting b/bin/notify-starting
new file mode 100755
index 0000000..4966bd6
--- /dev/null
+++ b/bin/notify-starting
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+notify-send -u low "$1" 'Unit is starting' --icon=dialog-information
diff --git a/bin/share b/bin/share
new file mode 100755
index 0000000..5e19d59
--- /dev/null
+++ b/bin/share
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -u
+set -e
+
+name=$(basename $1)
+user="dadada"
+host="share.dadada.li"
+w3dir="share"
+pubname="$(sha256sum $1 | cut -d " " -f 1)"
+
+ssh ${user}@${host} "mkdir -p ${w3dir}/${pubname}" > /dev/null
+scp $1 ${user}@${host}:${w3dir}/${pubname}/${name} > /dev/null
+echo "https://${host}/${pubname}/${name}"
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..2a11444
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,20 @@
+{ stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "dadadaScripts";
+  version = "1";
+
+  buildPhase = "";
+
+  installPhase = ''
+    mkdir -p $out/
+    cp -r bin $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Assorted scripts";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = [ "dadada" ];
+  };
+}

From 3393073cd3511d43f622972b891a20ba069fa052 Mon Sep 17 00:00:00 2001
From: dadada <dadada@dadada.li>
Date: Sun, 24 Jan 2021 19:00:03 +0100
Subject: [PATCH 2/2] Initial commit

---
 LICENSE             | 21 +++++++++++++++++++++
 bin/archpad         | 24 ++++++++++++++++++++++++
 bin/colortest       | 26 ++++++++++++++++++++++++++
 bin/lock-session    |  6 ++++++
 bin/notify-failed   |  3 +++
 bin/notify-finished |  3 +++
 bin/notify-starting |  3 +++
 bin/share           | 14 ++++++++++++++
 default.nix         | 22 ++++++++++++++++++++++
 9 files changed, 122 insertions(+)
 create mode 100644 LICENSE
 create mode 100755 bin/archpad
 create mode 100755 bin/colortest
 create mode 100755 bin/lock-session
 create mode 100755 bin/notify-failed
 create mode 100755 bin/notify-finished
 create mode 100755 bin/notify-starting
 create mode 100755 bin/share
 create mode 100644 default.nix

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..6d3d98f
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Tim Schubert
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/bin/archpad b/bin/archpad
new file mode 100755
index 0000000..3cfe4ff
--- /dev/null
+++ b/bin/archpad
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+url="$1"
+pad=$(basename $url).txt
+dst="$2"
+gitdir="$(dirname $dst)"
+
+wget -Q 10m -O "${dst}" "${url}/export/txt"
+status="$?"
+
+if [ ${status} -ne 0 ]; then
+	echo "Failed to get pad at ${url}"
+	return ${status}
+else
+	git -C "${gitdir}" add "${dst}"
+	changes=$(git -C "${gitdir}" diff --cached | wc -l)
+	if [ $changes -gt 0 ]; then
+		git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}"
+	else
+		echo "Nothing changed for ${url}"
+	fi
+fi
+
+git -C "${gitdir}" reset --hard HEAD
diff --git a/bin/colortest b/bin/colortest
new file mode 100755
index 0000000..d5b5a0c
--- /dev/null
+++ b/bin/colortest
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+#
+#   This file echoes a bunch of color codes to the 
+#   terminal to demonstrate what's available.  Each 
+#   line is the color code of one forground color,
+#   out of 17 (default + 16 escapes), followed by a 
+#   test use of that color on all nine background 
+#   colors (default + 8 escapes).
+#
+
+T='gYw'   # The test text
+
+echo -e "\n                 40m     41m     42m     43m\
+     44m     45m     46m     47m";
+
+for FGs in '    m' '   1m' '  30m' '1;30m' '  31m' '1;31m' '  32m' \
+           '1;32m' '  33m' '1;33m' '  34m' '1;34m' '  35m' '1;35m' \
+           '  36m' '1;36m' '  37m' '1;37m';
+  do FG=${FGs// /}
+  echo -en " $FGs \033[$FG  $T  "
+  for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
+    do echo -en "$EINS \033[$FG\033[$BG  $T  \033[0m";
+  done
+  echo;
+done
+echo
diff --git a/bin/lock-session b/bin/lock-session
new file mode 100755
index 0000000..6225bb5
--- /dev/null
+++ b/bin/lock-session
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+qdbus org.keepassxc.KeePassXC.MainWindow /keepassxc org.keepassxc.MainWindow.lockAllDatabases
+swaymsg 'output * dpms off'
+swaylock -c 1f2022
+swaymsg 'output * dpms on'
diff --git a/bin/notify-failed b/bin/notify-failed
new file mode 100755
index 0000000..231a476
--- /dev/null
+++ b/bin/notify-failed
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+notify-send -u critical "$1" 'Unit failed' --icon=dialog-warning
diff --git a/bin/notify-finished b/bin/notify-finished
new file mode 100755
index 0000000..7201a77
--- /dev/null
+++ b/bin/notify-finished
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+notify-send -u low "$1" 'Unit finished' --icon=dialog-information
diff --git a/bin/notify-starting b/bin/notify-starting
new file mode 100755
index 0000000..4966bd6
--- /dev/null
+++ b/bin/notify-starting
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+notify-send -u low "$1" 'Unit is starting' --icon=dialog-information
diff --git a/bin/share b/bin/share
new file mode 100755
index 0000000..5e19d59
--- /dev/null
+++ b/bin/share
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+set -u
+set -e
+
+name=$(basename $1)
+user="dadada"
+host="share.dadada.li"
+w3dir="share"
+pubname="$(sha256sum $1 | cut -d " " -f 1)"
+
+ssh ${user}@${host} "mkdir -p ${w3dir}/${pubname}" > /dev/null
+scp $1 ${user}@${host}:${w3dir}/${pubname}/${name} > /dev/null
+echo "https://${host}/${pubname}/${name}"
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..124e906
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,22 @@
+{ stdenv }:
+
+stdenv.mkDerivation rec {
+  name = "dadadaScripts";
+  version = "1";
+
+  src = ./.;
+
+  buildPhase = "";
+
+  installPhase = ''
+    mkdir -p $out/
+    cp -r bin $out/
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Assorted scripts";
+    license = licenses.mit;
+    platforms = platforms.linux;
+    maintainers = [ "dadada" ];
+  };
+}