From 546a3a211a0d59f14edbd97c1990476e84a46247 Mon Sep 17 00:00:00 2001 From: Raul Benencia Date: Sun, 24 May 2020 13:44:14 -0700 Subject: Add bin/ repo from home-bin/ repo --- bin/dim-screen.sh | 51 ++++++++++ bin/emacs-pkg-install | 45 +++++++++ bin/i3lock-wrapper | 5 + bin/mutt-displayfilter-gpg | 52 ++++++++++ bin/mutt-fetchbug | 161 ++++++++++++++++++++++++++++++ bin/mutt-open | 76 ++++++++++++++ bin/mutt-remember-mail | 23 +++++ bin/pycombine | 240 +++++++++++++++++++++++++++++++++++++++++++++ bin/touchpad-enable-tap | 7 ++ bin/xrandr-rul | 21 ++++ 10 files changed, 681 insertions(+) create mode 100755 bin/dim-screen.sh create mode 100755 bin/emacs-pkg-install create mode 100755 bin/i3lock-wrapper create mode 100755 bin/mutt-displayfilter-gpg create mode 100755 bin/mutt-fetchbug create mode 100755 bin/mutt-open create mode 100755 bin/mutt-remember-mail create mode 100755 bin/pycombine create mode 100755 bin/touchpad-enable-tap create mode 100755 bin/xrandr-rul diff --git a/bin/dim-screen.sh b/bin/dim-screen.sh new file mode 100755 index 0000000..949ed85 --- /dev/null +++ b/bin/dim-screen.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Debian package: xbacklight + +# Brightness will be lowered to this value. +min_brightness=0 + +# If your video driver works with xbacklight, set -time and -steps for fading +# to $min_brightness here. Setting steps to 1 disables fading. +fade_time=2000 +fade_steps=200 + +# Time to sleep (in seconds) between increments when using sysfs. If unset or +# empty, fading is disabled. +fade_step_time=0.05 + + +get_brightness() { + if [[ -z $sysfs_path ]]; then + xbacklight -get + else + cat $sysfs_path + fi +} + +set_brightness() { + if [[ -z $sysfs_path ]]; then + xbacklight -steps 1 -set $1 + else + echo $1 > $sysfs_path + fi +} + +fade_brightness() { + if [[ -z $sysfs_path ]]; then + xbacklight -time $fade_time -steps $fade_steps -set $1 + elif [[ -z $fade_step_time ]]; then + set_brightness $1 + else + local level + for level in $(eval echo {$(get_brightness)..$1}); do + set_brightness $level + sleep $fade_step_time + done + fi +} + +trap 'exit 0' TERM INT +trap "set_brightness $(get_brightness); kill %%" EXIT +fade_brightness $min_brightness +sleep 2147483647 & +wait diff --git a/bin/emacs-pkg-install b/bin/emacs-pkg-install new file mode 100755 index 0000000..93b747f --- /dev/null +++ b/bin/emacs-pkg-install @@ -0,0 +1,45 @@ +#!/bin/bash +# Gotten from: https://gist.github.com/padawanphysicist/d6299870de4ef8ad892f +# +# I wrapped the code constructed in +# +# http://hacks-galore.org/aleix/blog/archives/2013/01/08/install-emacs-packages-from-command-line +# +# in a single bash script, so I would a single code snippet. +# + + +# Elisp script is created as a temporary file, to be removed after installing +# the package +elisp_script_name=$(mktemp /tmp/emacs-pkg-install-el.XXXXXX) +elisp_code=" +;; +;; Install package from command line. Example: +;; +;; $ emacs --batch --expr \"(define pkg-to-install 'smex)\" -l emacs-pkg-install.el +;; +(require 'package) +(package-initialize) +(add-to-list 'package-archives + '(\"melpa\" . \"http://melpa.milkbox.net/packages/\") t) +;;(add-to-list 'package-archives +;; '(\"marmalade\" . \"http://marmalade-repo.org/packages/\") t) +;; Fix HTTP1/1.1 problems +(setq url-http-attempt-keepalives nil) +(package-refresh-contents) +(package-install pkg-to-install)" + +echo "$elisp_code" > $elisp_script_name + +if [ $# -lt 1 ] +then + echo "Usage: `basename $0` ..." + exit 1 +fi + +for pkg_name in $@; do + emacs --batch --eval "(defconst pkg-to-install '$pkg_name)" -l $elisp_script_name +done + +# Remove tmp file +rm "$elisp_script_name" diff --git a/bin/i3lock-wrapper b/bin/i3lock-wrapper new file mode 100755 index 0000000..7c8d8e2 --- /dev/null +++ b/bin/i3lock-wrapper @@ -0,0 +1,5 @@ +#!/bin/bash + +killall -SIGUSR1 dunst +i3lock --nofork -c "#000000" -e -f +killall -SIGUSR2 dunst diff --git a/bin/mutt-displayfilter-gpg b/bin/mutt-displayfilter-gpg new file mode 100755 index 0000000..ccd99d1 --- /dev/null +++ b/bin/mutt-displayfilter-gpg @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Copyright 2017 Sebastian Schmittner + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +""" +import re +import sys + + +def shorten_tofu_blocks(input): + pattern = r"(?s)gpg: Verified ([0-9]+) .*(ago|as being bad)\." + replace = r"gpg: TOFU \1" + return re.sub(pattern, replace, input) + + +def remove_aka_list(input): + pattern = r"gpg:[ \t]+aka [^\n]*\n" + replace = "" + return re.sub(pattern, replace, input) + + +def shorten_untrusted_warning(input): + pattern = r"(?s)gpg: WARNING: This key is not certified with sufficiently trusted signatures!.*key fingerprint: [^\n]+" + replace = "gpg: WARNING: untrusted signature" + return re.sub(pattern, replace, input) + + +def main(): + input = sys.stdin.read() + input = shorten_tofu_blocks(input) + input = remove_aka_list(input) + input = shorten_untrusted_warning(input) + sys.stdout.write(input) + + +# goto main +if __name__ == "__main__": + main() diff --git a/bin/mutt-fetchbug b/bin/mutt-fetchbug new file mode 100755 index 0000000..93ffc58 --- /dev/null +++ b/bin/mutt-fetchbug @@ -0,0 +1,161 @@ +#!/usr/bin/perl -w +# +# mutt-fetchbug, extensively based off of +# mutt-notmuch - notmuch (of a) helper for Mutt +# +# Copyright: © 2011 Stefano Zacchiroli +# License: GNU General Public License (GPL), version 3 or above +# +# Differences between mutt-notmuch and mutt-fetchbug are +# Copyright: © 2012 Ryan Kavanagh +# License: GNU General Public License (GPL), version 3 or above +# +# See the bottom of this file for more documentation. +# A manpage can be obtained by running "pod2man mutt-fetchbug > mutt-fetchbug.1" + +use strict; +use warnings; + +use File::Path; +use Getopt::Long; +use Pod::Usage; + +# search($btsmbox, $query) +# Fetch bugs matching $query with bts; store results in $btsmbox +sub search($$) { + my ($btsmbox, $query) = @_; + + system("bts --cache-mode=mbox cache $query" + . " && ln -fs ~/.cache/devscripts/bts/$query.mbox $btsmbox"); +} + +sub search_action($$@) { + my ($interactive, $btsmbox, @params) = @_; + + if (! $interactive) { + fetch($btsmbox, join(' ', @params)); + } else { + my $query = ""; + my $done = 0; + while (! $done) { + print "bug number ('?' for man): "; + chomp($query = ); + if ($query eq "?") { + system("man bts"); + } elsif ($query eq "") { + $done = 1; # quit doing nothing + } else { + search($btsmbox, $query); + $done = 1; + } + } + } +} + +sub die_usage() { + my %podflags = ( "verbose" => 1, + "exitval" => 2 ); + pod2usage(%podflags); +} + +sub main() { + my $btsmbox = "$ENV{HOME}/.cache/mutt_btsresults"; + my $interactive = 0; + my $help_needed = 0; + + my $getopt = GetOptions( + "h|help" => \$help_needed, + "o|output-mbox=s" => \$btsmbox, + "p|prompt" => \$interactive); + if (! $getopt || $#ARGV < 0) { die_usage() }; + my ($action, @params) = ($ARGV[0], @ARGV[1..$#ARGV]); + + if ($help_needed) { + die_usage(); + } elsif ($action eq "search" && $#ARGV == 0 && ! $interactive) { + print STDERR "Error: no search term provided\n\n"; + die_usage(); + } elsif ($action eq "search") { + search_action($interactive, $btsmbox, @params); + } else { + die_usage(); + } +} + +main(); + +__END__ + +=head1 NAME + +mutt-fetchbug - 'bts show' frontend for Mutt + +=head1 SYNOPSIS + +=over + +=item B [I