summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/chrome-extension-dl83
-rwxr-xr-xbin/fs14
-rwxr-xr-xbin/kp75
-rwxr-xr-xbin/mesoninit191
-rwxr-xr-xbin/once47
-rwxr-xr-xbin/open53
-rwxr-xr-xbin/wsudo44
7 files changed, 0 insertions, 507 deletions
diff --git a/bin/chrome-extension-dl b/bin/chrome-extension-dl
deleted file mode 100755
index a40b519..0000000
--- a/bin/chrome-extension-dl
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env sh
-# Download extensions from chrome webstore
-#
-# source: https://gitlab.com/snippets/1888145
-
-[ -z "$EXTENSIONS_DIR" ] && EXTENSIONS_DIR="${extensions_dir:=${XDG_DATA_HOME:=$HOME/.local/share}/chrome-extensions}"
-
-magenta="\033[35;1m"
-nc="\033[m"
-
-die() { printf 'Error: %s\n' "$1" >&2; exit 1; }
-
-parse_url(){
-    extension_id="$(echo "$1" | grep -oP '[_a-zA-Z0-9]{30,}')"
-    download_extension
-}
-
-download_extension(){
-    extension_file="$(mktemp "${TMPDIR:-/tmp/}$extension_id.XXXXXXXXXXXX.zip")"
-    printf "\nDownloading extension %s\n" "$extension_id"
-    curl -fsSL "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=49.0&x=id%3D$extension_id%26installsource%3Dondemand%26uc" --output "$extension_file" || die "Unable to download extension"
-    extract_extension
-}
-
-extract_extension(){
-    nohup rm -fr "$extensions_dir/${extension_id:?}" > /dev/null 2>&1 ||:
-    mkdir -p "$extensions_dir/$extension_id"
-    nohup unzip -q "$extension_file" -d "$extensions_dir/$extension_id" > /dev/null 2>&1
-    printf "\n Extension installed to directory %s\n" "$extensions_dir/$extension_id"
-    install_help
-}
-
-update_extensions(){
-    cd "$extensions_dir" || die "Extensions directory does not exist"
-    for extension in *; do
-        if [ -d "$extension" ]; then
-            printf "\nUpdating extension %s\n" "$extension"
-            extension_id="$extension"
-            download_extension
-        fi
-    done
-}
-
-general_help(){
-    echo -e "
-    ${magenta}NAME${nc}
-    $(basename "$0") - install chrome extensions
-
-    ${magenta}SYNOPSIS${nc}
-    $(basename "$0") [webstore url]
-    $(basename "$0") update
-
-    ${magenta}DESCRIPTION${nc}
-    $(basename "$0") Download extensions from chrome webstore.
-
-    set EXTENSIONS_DIR to change extensions folder."
-}
-
-install_help(){
-    echo -e "
-    ${magenta}Install Guide:${nc}
-    1. Visit chrome://extensions in your browser.
-    2. Ensure that the Developer mode checkbox in the top right-hand corner is checked.
-    3. Click Load unpacked extension... to pop up a file-selection dialog.
-    4. Navigate to $extensions_dir/, and select it."
-}
-
-main(){
-    if [ "$#" -eq 0 ]; then
-        general_help && install_help
-    else
-        for input in "$@"; do
-            shift
-            case "$input" in
-                -h|--h*) general_help && install_help ;;
-                u*) update_extensions ;;
-                *)  parse_url "$input" ;;
-            esac
-        done
-    fi
-}
-
-main "$@"
diff --git a/bin/fs b/bin/fs
deleted file mode 100755
index 0586ab5..0000000
--- a/bin/fs
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-set -e
-
-dir=$(readlink -f -- "$1" || pwd)
-
-# _rect=$(swq current output-full | jq -r '.rect')
-# w=$(echo "${_rect}" | jq -r '.width * 0.6')
-# h=$(echo "${_rect}" | jq -r '.height * 0.6')
-# x=$(echo "${_rect}" | jq -r "((.width - ${w}) / 2) + .x")
-# y=$(echo "${_rect}" | jq -r "((.height - ${h}) / 2) + .y")
-
-echo "$dir"
-# exec swx -t -g "${x},${y} ${w}x${h}" fzfez fd -a -p "${dir}"
-exec swx -t -F 0.6 fzfez fd -a -p "${dir}"
diff --git a/bin/kp b/bin/kp
deleted file mode 100755
index f578b04..0000000
--- a/bin/kp
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/sh
-
-set -e -o pipefail
-
-KP="$HOME/.local/bin/KeePassXC-2.5.1-x86_64.AppImage"
-[ -e "$KP" ] || {
-    echo "$KP not found" >&2; exit 1
-}
-
-DB="${KP_DB:-$HOME/Dropbox/keepass-box.kdbx}"
-[ -e "$DB" ] || {
-    echo "$DB not found" >&2; exit 1
-}
-
-keepass()
-{
-    "$KP" $@
-}
-
-wofi()
-{
-    wofi -k /dev/null --dmenu --prompt 'Select an entry'
-}
-
-unset passwd
-passwd="$(ASKPASS_PROMPT='Enter KeePassXC password' askpass)"
-[ -n "$passwd" ] || {
-    echo "No password" >&2; exit 1
-}
-
-_kp_command=show
-_kp_opts='-q -a Password'
-_kp_extra_args=
-case $1 in
-    clip)
-        _kp_command='clip'
-        _kp_opts='-q'
-        _kp_extra_args='15' # timeout
-        shift
-        ;;
-    dump)
-        echo "$passwd" | keepass cli export -f csv "$DB"
-        exit 0
-        ;;
-esac
-
-entry="$1"
-[ -n "$entry" ] || {
-    entry=$(echo "$passwd" \
-        | keepass cli ls -q -R "$DB" \
-        | awk '
-{
-    if ($0~/\/$/) { 
-        sub(/^\s+/, "")
-        if ($0!~/^\s+/) {
-            grp = $0
-        } else {
-            print substr($0, match($0, /^\s+/))
-            grp = grp $0
-        }
-            next 
-    } else { 
-        sub(/^\s+/, "")
-        print "/" grp $0 
-    } 
-}' \
-        | grep -v '^/Recycle Bin' \
-        | sort -t/ -k2n \
-        | wofi)
-    [ -n "$entry" ] || {
-        echo "No entry" >&2; exit 1
-    }
-}
-
-echo "$passwd" | keepass cli "$_kp_command" "$_kp_opts" "$DB" "$entry" "$_kp_extra_args"
diff --git a/bin/mesoninit b/bin/mesoninit
deleted file mode 100755
index 5ce3b79..0000000
--- a/bin/mesoninit
+++ /dev/null
@@ -1,191 +0,0 @@
-#!/bin/bash
-# vim: ft=sh
-
-_meson_dir=`pwd`
-_meson_lang=c
-
-while getopts ":hl:" o; do
-    case $o in
-        l)
-            _meson_lang=$OPTARG
-            ;;
-        h | *)
-            echo "usage: $0 [flags]"
-            echo ""
-            echo "-h :: print help"
-            echo "-l LANG (default: c) :: language to use"
-            echo ""
-            exit 0
-            ;;
-    esac
-done
-shift $((OPTIND - 1))
-
-log() {
-    echo "[*] ${@}" >&2
-}
-
-# allow setting target dir
-if [[ -n $1 ]]; then
-    _meson_dir="$1"
-    [[ ! -d $_meson_dir ]] && mkdir -p $_meson_dir
-    log "creating in $_meson_dir"
-fi
-
-_meson_bin=`basename $_meson_dir`
-_meson_ignore_extra=
-declare -a _meson_default_options
-declare -a _meson_default_files
-
-case $_meson_lang in
-
-    ### C ###
-    c)
-        _meson_default_options=( \
-            'c_std=c11' \
-            'warning_level=2' \
-            'werror=true' \
-        )
-        _meson_default_files=('src/main.c')
-        _meson_ignore_extra='**/*.o'
-        _meson_output="
-x = executable(
-    '$_meson_bin',
-    sources: src
-)"
-
-        log "writing main.c"
-        mkdir $_meson_dir/src
-        cat > $_meson_dir/src/main.c <<EOF
-#define _POSIX_C_SOURCE 200809L
-
-#ifndef VERSION
-#define VERSION "undefined"
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-
-int main(int argc, char **argv) {
-    printf("%s version %s\n\n", *argv, VERSION);
-
-    printf("args (len: %d)", argc-1);
-    for (int i=1; i < argc; ++i) {
-        printf(" '%s'", argv[i]);
-    }
-    printf("\n");
-    return 0;
-}
-EOF
-        ;;
-
-    ### JAVA ###
-    java)
-        _meson_default_options=
-        _meson_default_files=('pkg/Main.class')
-        _meson_ignore_extra='**/*.jar'
-        _meson_output="
-x = jar(
-    '$_meson_bin',
-    main_class: 'pkg.Main',
-    sources: src
-)
-"
-
-        log "writing Main.java"
-        mkdir $_meson_dir/pkg
-        cat > $_meson_dir/pkg/Main.java <<EOF
-package pkg
-
-class Main {
-    public static void main(String[] args) {
-        System.out.println("hello world o/");
-    }
-}
-EOF
-        ;;
-
-
-    *)
-        log "$_meson_lang not supported yet :("
-        exit 1
-        ;;
-esac
-
-meson_array_expand() {
-    for o in "${@}"; do 
-        printf "\t'%s',\n" $o
-    done
-}
-
-log "writing meson.build"
-cat > $_meson_dir/meson.build <<EOF
-project(
-    '$_meson_bin',
-    '$_meson_lang',
-    version: '0.1.0',
-    license: 'MIT',
-    default_options: [
-`meson_array_expand ${_meson_default_options[@]}`
-    ],
-)
-
-version = '"@0@ (" __DATE__ ")"'.format(meson.project_version())
-
-# embed version sourced from git ref
-git = find_program('git', native: true, required: false)
-if git.found()
-    git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags'])
-    git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD'])
-    if git_commit_hash.returncode() == 0 and git_branch.returncode() == 0
-	version = '"@0@ (" __DATE__ ", branch \'@1@\')"'.format(git_commit_hash.stdout().strip(), git_branch.stdout().strip())
-    endif
-endif
-add_project_arguments('-DVERSION=@0@'.format(version), language: 'c')
-
-src = files(
-`meson_array_expand ${_meson_default_files[@]}`
-)
-
-$_meson_output
-
-test('smoke', x)
-EOF
-
-log "intialializing git"
-git init -q $_meson_dir
-
-log "writing .gitignore"
-cat > $_meson_dir/.gitignore <<EOF
-/build
-$_meson_ignore_extra
-EOF
-
-log "writing Makefile"
-cat > $_meson_dir/Makefile <<EOF
-RT ?= podman
-IMAGE ?= docker.io/robertgzr/mesonbuild-$_meson_lang
-
-all: clean compile
-
-build/build.ninja:
-	meson build
-
-build/$_meson_bin$([[ $_meson_lang -eq java ]] && echo '.jar'): compile
-build: build/build.ninja
-	ninja -C build
-
-test: build/$_meson_bin$([[ $_meson_lang -eq java ]] && echo '.jar')
-	ninja -C build test
-
-cbuild:
-        \$(RT) run --rm -it -v \$(shell pwd):/src -w /src \$(IMAGE) make
-
-ctest:
-        \$(RT) run --rm -it -v \$(shell pwd):/src -w /src \$(IMAGE) make test
-
-clean:
-	\$(RM) -r build
-
-.PHONY: clean build test cbuild ctest
-EOF
diff --git a/bin/once b/bin/once
deleted file mode 100755
index 1655368..0000000
--- a/bin/once
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-set -e
-[ -n "$DEBUG" ] && set -x
-
-_check_running=
-ssd_args="--background --make-pidfile --start"
-while getopts rsKkl:h opt; do
-	case "$opt" in
-	K|k)   ssd_args='--stop';;
-	l)     ssd_args="${ssd_args} --stdout ${OPTARG} --stderr ${OPTARG}";;
-	s)     _check_running=1 ;;
-	r)     _restart=1 ;;
-
-	h)
-		printf "usage: %s [-h]\n" "$(basename "$0")"
-		printf "\n"
-		printf "  -K -k          kill the service\n"
-		printf "     -l LOGFILE  log to a file\n"
-		printf "\n"
-		exit 2 ;;
-	esac
-done
-shift $((OPTIND - 1))
-
-exec="${1:-}"
-[ -z "${exec}" ] && exit 1
-shift
-
-if [ -n "$_check_running" ]
-then
-	[ -f "${XDG_RUNTIME_DIR}/${exec}.pid" ] && exit 0
-	exit 1
-fi
-
-if [ -n "$_restart" ]
-then
-	set -x
-	${0} -k ${exec} ${@}
-	${0} ${exec} ${@}
-	exit 0
-fi
-
-start-stop-daemon \
-	--pidfile "${XDG_RUNTIME_DIR:-/tmp}/${exec}.pid" \
-	$ssd_args \
-	"${exec}" -- "${@}"
diff --git a/bin/open b/bin/open
deleted file mode 100755
index ba809bf..0000000
--- a/bin/open
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/bash
-
-set -m
-termmode=0
-
-while getopts ":hg" opt; do
-    case $opt in
-        g)
-            termmode=1
-            ;;
-        h|*)
-            echo "usage: open [-t] FILE"
-            echo ""
-            echo "  -t  Use only Terminal-based applications"
-            exit 2
-            ;;
-    esac
-done
-shift $((OPTIND-1))
-
-in="$1"
-
-mime=$(file --mime-type "$in" | awk -F': ' '{print $2}' )
-ext=$(basename "$in" | rev | cut -d'.' -f1 | rev)
-opener=xdg-open
-
-fork() {
-    exec $@ >/dev/null 2>&1 &
-}
-term() {
-    fork alacritty --title="$1" --command "$@"
-}
-
-case $mime in
-    inode/directory)    [ $termmode -eq 0 ] && vifm "$in" ;;
-    inode/file)         [ $termmode -eq 0 ] && vifm "$in" ;;
-
-    image/*)            fork mvi "$in" ;;
-    video/*)            fork mpv --force-window=yes "$in" ;;
-    audio/*)            fork mpv --force-window=yes "$in" ;;
-
-    application/pdf)    fork zathura "$in" ;;
-    # application/vnd.ms-opentype|application/font-sfnt)
-                        # fork gnome-font-viewer "$in" ;;
-
-    # now text...
-    text/md|text/markdown)
-                        fork shiba "$(readlink -f "$in")" ;;
-    text/*)             fork term ${EDITOR} "$in" ;;
-
-    # everything else...
-    *) exec $opener "$in" ;;
-esac
diff --git a/bin/wsudo b/bin/wsudo
deleted file mode 100755
index 1ac1e33..0000000
--- a/bin/wsudo
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Enable root access to x-windows system.
-#
-# Motivation: Trying to run a graphical application as root via su, sudo in a 
-# Wayland session (e.g. GParted or Gedit), will fail. Apps which use polkit to
-# request administrator permissions for just certain operations and only when 
-# needed are not affected (they are not started as root right away). 
-# [1] https://bugzilla.redhat.com/show_bug.cgi?id=1274451
-#
-# Based on a Reddit comment.
-# [2] https://www.reddit.com/r/Fedora/comments/5eb633/solution_running_graphical_app_with_sudo_in/
-
-usage() {
-    printf "usage: wsudo [-d] [command]\n"
-}
-
-# make sure there is an argument
-if (( $# == 0 )); then
-    echo "error: Illegal number of parameters." >&2
-    exit 1
-fi
-
-if ! type -p "$1" &>/dev/null; then
-    echo "$1 not found. Aborting." >&2
-    exit 1
-fi
-
-for cmd in sudo xhost; do
-    if ! type -P $cmd &>/dev/null; then
-        echo "$cmd it's not installed. Aborting." >&2
-        exit 1
-    fi
-done
-
-set -x
-
-xhost +SI:localuser:root
-SUDO_ASKPASS="`command -v askpass`" sudo -A "${@}"
-#disable root access after application terminates
-xhost -SI:localuser:root
-#print access status to allow verification that root access was removed
-xhost