From c2e0ef5886c3a197253c213de2f3e0a888edad6f Mon Sep 17 00:00:00 2001 From: dadada Date: Sun, 24 Jan 2021 19:00:03 +0100 Subject: [PATCH] Initial commit --- LICENSE | 21 +++++++++++++++++++++ archpad | 24 ++++++++++++++++++++++++ colortest | 26 ++++++++++++++++++++++++++ default.nix | 22 ++++++++++++++++++++++ lock-session | 6 ++++++ notify-failed | 3 +++ notify-finished | 3 +++ notify-starting | 3 +++ share | 14 ++++++++++++++ 9 files changed, 122 insertions(+) create mode 100644 LICENSE create mode 100755 archpad create mode 100755 colortest create mode 100644 default.nix create mode 100755 lock-session create mode 100755 notify-failed create mode 100755 notify-finished create mode 100755 notify-starting create mode 100755 share 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/archpad b/archpad new file mode 100755 index 0000000..3cfe4ff --- /dev/null +++ b/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/colortest b/colortest new file mode 100755 index 0000000..d5b5a0c --- /dev/null +++ b/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/default.nix b/default.nix new file mode 100644 index 0000000..d72c871 --- /dev/null +++ b/default.nix @@ -0,0 +1,22 @@ +{ stdenv }: + +stdenv.mkDerivation rec { + name = "dadadaScripts"; + version = "1"; + + #src = ./src; + + buildPhase = ""; + + installPhase = '' + mkdir -p $out/bin + cp * $out/bin + ''; + + meta = with stdenv.lib; { + description = "Assorted scripts"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = [ "dadada" ]; + }; +} diff --git a/lock-session b/lock-session new file mode 100755 index 0000000..6225bb5 --- /dev/null +++ b/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/notify-failed b/notify-failed new file mode 100755 index 0000000..231a476 --- /dev/null +++ b/notify-failed @@ -0,0 +1,3 @@ +#!/bin/sh + +notify-send -u critical "$1" 'Unit failed' --icon=dialog-warning diff --git a/notify-finished b/notify-finished new file mode 100755 index 0000000..7201a77 --- /dev/null +++ b/notify-finished @@ -0,0 +1,3 @@ +#!/bin/sh + +notify-send -u low "$1" 'Unit finished' --icon=dialog-information diff --git a/notify-starting b/notify-starting new file mode 100755 index 0000000..4966bd6 --- /dev/null +++ b/notify-starting @@ -0,0 +1,3 @@ +#!/bin/sh + +notify-send -u low "$1" 'Unit is starting' --icon=dialog-information diff --git a/share b/share new file mode 100755 index 0000000..5e19d59 --- /dev/null +++ b/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}"