summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-09-20 11:45:19 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-09-20 11:45:19 +0200
commitecca3740145157b468064258974f505cc5c6771b (patch)
tree2654bb62183e3af3b2023ad8a4d9c708eee80d1e
parentd9cc15bce788c57789982a0da10fd5720b93d412 (diff)
parentcd7abd1c2a045f6b824fdcad864693b85cd84d61 (diff)
Merge branch 'main' of db:dotfiles
-rwxr-xr-xbin/common/aumount97
-rwxr-xr-xbin/guiscripts/keyadd75
-rwxr-xr-xbin/menuscripts/commander321
-rwxr-xr-xbin/menuscripts/mmedia52
-rwxr-xr-xbin/menuscripts/mpass27
-rwxr-xr-xconfig/X/x11/xinitrc1
-rw-r--r--config/home/.zshenv2
-rw-r--r--config/hyprland/hypr/env.conf1
8 files changed, 4 insertions, 572 deletions
diff --git a/bin/common/aumount b/bin/common/aumount
deleted file mode 100755
index 8a2b785..0000000
--- a/bin/common/aumount
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/sh
-
-tmp="$(mktemp)"
-test "$(id -u)" != "0" && sudo="sudo"
-
-logn () { >&2 printf "%s\n" "$@"; }
-log () { >&2 printf '%s' "$@"; }
-
-# Read one character
-read_char ()
-{
- log ">"
- old_stty_cfg=$(stty -g)
- stty raw
- dd ibs=1 count=1 2> /dev/null
- stty "$old_stty_cfg"
- logn ""
-}
-
-get_dev () { grep "^$1\." "$tmp" | cut -f 2- -d ' '; }
-
-# mount the device with $1 as the choice
-mount ()
-{
- dev="$(get_dev "$1")"
- test -z "$dev" && exit 1
-
- logn "Mounting /dev/$dev on /media/$dev"
- mkdir -p /media/"$dev"
- $sudo mount /dev/"$dev" /media/"$dev" > /dev/null 2>&1 ||
- return 1
-}
-
-# umount the device with $1 as the choice
-umount ()
-{
- mountpoint="$(sed -n "${1}p" "$tmp" | awk '{print $3}')"
- test -z "$mountpoint" && exit 1
-
- logn "Unmounting $mountpoint"
- $sudo umount "$mountpoint" ||
- return 1
-}
-
-ejekt ()
-{
- dev="$(get_dev "$1" | sed 's/.$//')"
- test -z "$dev" && exit 1
-
- logn "Ejecting /dev/$dev"
- $sudo eject /dev/"$dev" > /dev/null 2>&1 ||
- return 1
-}
-
-# print lsblk, use $1 to print only devices with mountpoints or without
-pr_lsblk ()
-{
- clear
- lsblk -o name,size,type,mountpoint
- logn "───────────────────────────────────"
- lsblk --ascii -o name,mountpoint |
- grep '^.-' |
- while read -r line
- do
- words="$(printf "%s" "$line" | wc -w)"
- test "$words" -eq "${1:-1}" && continue
- printf "%s\n" "$line"
- done |
- cut -f 2- -d "-" |
- awk '{print NR ". " $0}' |
- tee "$tmp" >&2
-}
-
-cleanup () { rm -f "$tmp"; }
-
-trap cleanup EXIT INT
-
-logn "m(ount) u(mount) (e)ject ?"
-choice="$(read_char)"
-
-case $choice in
- "m") i=2; cmd=mount ;;
- "u") i=1; cmd=umount ;;
- "e") i=2; cmd=ejekt ;;
- *) exit 1 ;;
-esac
-
-pr_lsblk "$i"
-choice="$(read_char)"
-printf "%s" "$choice" | grep -q "[0-9]" || exit 1
-
-if $cmd "$choice"
-then
- logn "Successful."
-else
- logn "Failed."
-fi
diff --git a/bin/guiscripts/keyadd b/bin/guiscripts/keyadd
deleted file mode 100755
index cb81efe..0000000
--- a/bin/guiscripts/keyadd
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/sh
-
-# For when script calls itself
-if [ -n "$PASSWORD" ]
-then
- pass show "$PASSWORD" &&
- exit
- exit 1
-fi
-
-
-if [ "$MENUCMD" = "tofi" ]
-then
- menucmd="tofi --matching-algorithm=normal"
-else
- menucmd="$MENUCMD"
-fi
-
-
-die ()
-{
- echo "$1" >&2
-}
-
-notify ()
-{
- notify-send -t 1000 "keyadd" "$1"
- die "$1"
-}
-
-
-SSHFOLDER="$HOME/.ssh"
-
-# Test if can connect to ssh-agent
-ssh-add -l > /dev/null 2>&1
-if [ $? -gt 1 ] # ignore if there are no identities
-then
- notify "Could not connect to agent."
- exit 1
-fi
-
-if [ -z "${key:=$1}" ]
-then
- key="$(find "$SSHFOLDER" -iname "*.pub" |
- sed "s,$SSHFOLDER/,," | # Clean
- sed 's/\.pub$//' |
- $menucmd)"
-else
- shift
-fi
-die "key: $key"
-
-[ ! -f "$SSHFOLDER/$key" ] && exit 1
-
-HOST=$(hostnamectl hostname)
-die "host: $HOST"
-
-if [ "$1" = "-d" ]
-then
- if ssh-add -q -d - < "$SSHFOLDER"/"$key".pub 2> /dev/null
- then
- notify "Deleted <b>$key</b>"
- else
- notify "Could not delete."
- fi
-# check if key is already added
-elif ssh-add -l | grep -q "$(ssh-keygen -lf "$SSHFOLDER"/"$key")"
-then
- notify "Key already added."
-else
- export PASSWORD="keys/$HOST/ssh/$key"
- export SSH_ASKPASS="$0"
- ssh-add -q - < "$SSHFOLDER"/"$key" &&
- notify "Added <b>$key</b>."
-fi
diff --git a/bin/menuscripts/commander b/bin/menuscripts/commander
deleted file mode 100755
index d0a1454..0000000
--- a/bin/menuscripts/commander
+++ /dev/null
@@ -1,321 +0,0 @@
-#!/bin/sh
-
-# An attempt to unify usage of multiple launchers.
-# MENUCMD must be set to the name of the lancher
-#
-# look at the last line to understand how it works
-
-tmp="$(mktemp -u)"
-export menuopts=""
-TOFIRC="$HOME/.config/tofi/config"
-
-options='
-horizontal
-center
-input
-instant
-dynamic
-long
-prompt
-numbered
-prefix'
-
-cleanup() { rm -f "$tmp"; }
-
-logn()
-{
- [ "${log_on:=0}" -eq 0 ] && return
- >&2 printf '%s\n' "$@"
-}
-
-run() {
- IFS=:
- set -f
- find -L $PATH -type f -printf "%f\n" 2> /dev/null | sort -u
-}
-
-help() {
- cat <<-EOF
- Usage: commander OPTIONS...
-
- An attempt to regroup multiple launchers into one,
- it detects the value of the MENUCMD variable
-
- try:
- MENUCMD=tofi commander < /etc/passwd
-
- Options:
- -h Display items horizontally
- -c Display centered
- -i Take an input and return it to stdout
- -d Adjust size and style dynamically
- -p ARG Prompt user with the specified argument
- -l Display in long list format
- -n Output the number of matches
- -r Select an executable from PATH
- -s Invert instant select on single match
- -x Invert prefix matching
- EOF
-}
-
-add_option() { menuopts="$menuopts $*"; }
-get_prop() { awk -F '=' "/$1 *=*/ {print \$2}" "$TOFIRC"; }
-
-
-trap cleanup EXIT
-
-# Helper functions
-case "$MENUCMD" in
- "tofi")
- # $1: items count
- get_height()
- {
- font_size="$(get_prop "font-size")"
- padding_top="$(get_prop "padding-top")"
- padding_bottom="$(get_prop "padding-bottom")"
-
- printf "%s" "$((
- font_size*2 + padding_top + padding_bottom + 2 +
- ($1)*(font_size*2 - 2)
- ))"
-
- }
- # $1: items length
- get_width()
- {
- font_size="$(get_prop "font-size")"
- padding_left="$(get_prop "padding-left")"
- padding_right="$(get_prop "padding-right")"
- printf "%s" "$(($1*(font_size-2) + 2 + padding_left + padding_right))"
- } ;;
- "dmenu") ;;
- *) ;;
-esac
-
-
-main()
-{
- # shellcheck disable=SC2317
- case "$MENUCMD" in
- "tofi")
- center() { add_option "--anchor=center --width=20%"; }
-
- horizontal() {
- add_option "--horizontal=true --height=32"
- add_option "--result-spacing=12"
- add_option "--selection-background=#88c0d0"
- add_option "--selection-background-padding=6,4"
- add_option "--padding-top=0 --padding-bottom=0"
- add_option "--margin-top=4"
- }
-
- dynamic() {
- pre_cmd()
- {
- max_height="$(get_height 8)"
- max_width="$(get_width 64)"
-
- tee "$tmp"
-
- items_count="$(wc -l < "$tmp")"
- items_length="$(wc -L < "$tmp")"
-
- if [ "$long" -ne 1 ]
- then
- height="$(get_height "$items_count")"
- [ "$height" -gt "$max_height" ] && height="$max_height"
- add_option "--height=$height"
- fi
-
- width="$(get_width "$items_length")"
- [ "$width" -gt "$max_width" ] && width="$max_width"
-
-
- if [ "$prompt" -eq 1 ]
- then
- prompt_width="$(printf "%s" "$prompt_arg" | wc -c)"
- width="$((width + $(get_width "$prompt_width")))"
- fi
-
- add_option "--width=$width"
- }
- }
-
- long() { add_option "--width=100% --height=$(get_height 20)"; }
-
- input() {
- add_option "--height=$(get_height 0) --width=$(get_width 24)"
- pre_filter() { cat /dev/null; }
- }
-
- prefix() { add_option '--matching-algorithm=normal'; }
-
- instant() { add_option "--auto-accept-single=false"; }
-
- prompt() { add_option '--prompt-text' "$prompt_arg"; }
-
- numbered() {
- pre_filter() { awk '{print NR, $0}'; }
- post_filter() { awk '{print $1}'; }
- }
-
- menucmd() { tofi "$@"; }
- ;;
-
- "dmenu")
- horizontal() { add_option "-l 0"; }
-
- center() { add_option "-c"; }
-
- long() { add_option "-l 20 -g 1"; }
-
- input() {
- pre_filter() { cat /dev/null; }
- }
-
- dynamic() {
- pre_cmd()
- {
- tee "$tmp"
- items_count="$(wc -l < "$tmp")"
- number="$items_count"
-
- for i in $(seq $((number/2)))
- do [ "$((number%i))" -eq 0 ] && factors="$i $factors"
- done
-
- min_diff=9999999999
- for factor in $factors
- do
- quotient="$((number/factor))"
- diff=$((quotient - factor))
- if [ "$diff" -ge 0 ] && [ "$diff" -lt "$min_diff" ]
- then
- columns="$factor"
- rows="$quotient"
- min_diff="$diff"
- fi
- done
-
- add_option "-g $columns"
- add_option "-l $rows"
- }
- }
-
- instant() { add_option "-n"; }
-
- prefix() { add_option '-x'; }
-
- prompt() { add_option '-p' "$prompt_arg"; }
-
- numbered() { add_option "-px"; }
-
- menucmd() { dmenu "$@"; }
- ;;
-
- *)
- center() { :; }
-
- horizontal() { :; }
-
- dynamic() { :; }
-
- long() { :; }
-
- input() {
- pre_filter() { cat /dev/null; }
- add_option '--print-query'
- }
-
- instant() { :; }
-
- prefix() { :; }
-
- prompt() { add_option "--prompt" "$prompt_arg"; }
-
- numbered() {
- pre_filter() { awk '{print NR, $0}'; }
- add_option '--with-nth' '2..'
- post_filter() { awk '{print $1}'; }
- }
-
- menucmd() { fzf -0 -1 "$@"; }
- ;;
- esac
-
- for option in $options
- do eval "$option=0"
- done
-
- while getopts ":cdhilop:nrsxv" opt
- do
- # shellcheck disable=SC2034
- case $opt in
-
- # display horizontal
- h) horizontal=1 ;;
- # display centered
- c) center=1 ;;
- # take an input and return it on stdout
- i) input=1 ;;
- # adjust size and style dynamically
- d) dynamic=1 ;;
- p) prompt=1; prompt_arg="$OPTARG";;
- # long list format
- l) long=1 ;;
- # output number of match
- n) numbered=1 ;;
- # select an executable from PATH
- r) shift
- run | $0 "$@"
- exit ;;
- # invert instant select on single match
- s) instant=1 ;;
- # invert prefix matching
- x) prefix=1 ;;
- v) log_on=1 ;;
-
- :)
- logn "Option '-$OPTARG' requires an argument"
- help
- exit 1 ;;
- ?)
- logn "Invalid option: -$OPTARG"
- help
- exit 1 ;;
- esac
- done
-
-
- # conflicts
- [ "$input" -eq 1 ] && [ "$dynamic" -eq 1 ] && logn "conflicting options." && help && exit 1
-
- # quit if stdin is empty
- [ -t 0 ] && [ "$input" -eq 0 ] && logn "Stdin is empty." && help && exit 1
-
- # call options
- for option in $options
- do eval "test \"\$$option\" -eq 1" && $option
- done
-
- command -v pre_filter > /dev/null || pre_filter() { cat; }
- command -v post_filter > /dev/null || post_filter() { cat; }
-
- which "${MENUCMD:-fzf}" > /dev/null || exit 1
-
-
-
- if command -v pre_cmd > /dev/null
- then
- pre_cmd > "$tmp"
- logn "menuopts: $menuopts"
- # shellcheck disable=SC2086
- pre_filter < "$tmp" | menucmd $menuopts | post_filter
- else
- logn "menuopts: $menuopts"
- # shellcheck disable=SC2086
- pre_filter | menucmd $menuopts | post_filter
- fi
-}
-
-main "$@"
diff --git a/bin/menuscripts/mmedia b/bin/menuscripts/mmedia
deleted file mode 100755
index d113e76..0000000
--- a/bin/menuscripts/mmedia
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env sh
-
-tmp="/tmp/mmedia"
-
-dirs="$HOME/dl"
-
-concat_path() { sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g"; }
-
-case "$1" in
- "video")
- regex='^.\+\.\(webm\|mp4\|mpeg\|mkv\)$'
- dirs="$dirs $HOME/vids"
- viewer() { mpv "$1"; } ;;
- "pdf")
- regex='^.\+\.\(pdf\)$'
- dirs="$dirs $HOME/docs"
- viewer() { zathura "$1"; } ;;
- "images")
- regex='^.\+\.\(png\|avif\|jpg\)$'
- dirs="$dirs $HOME/pics"
- viewer() { imv "$1"; } ;;
- "cursus")
- regex='^.*/[cC]ursus/index.html$'
- dirs="$HOME/docs/school/Vakken"
- concat_path() { sed "s#$dirs/##;s#/[cC]ursus/index.html##"; }
- viewer() { $BROWSER "$1"; } ;;
- *)
- choice="$(cat <<-EOF | commander -d -c
- video
- pdf
- images
- cursus
- EOF
- )"
- [ "$choice" ] || exit 1
- "$0" "$choice"
- exit ;;
-esac
-
-shift
-[ "$1" ] && dirs="$1"
-
-choice="$(find -L $dirs 2> /dev/null |
- grep "$regex" |
- sort | tee "$tmp" |
- concat_path |
- commander -c -d -n -x)"
-
-file="$(sed -n "${choice}p" "$tmp")"
-[ -r "$file" ] || exit 1
-
-viewer "$file"
diff --git a/bin/menuscripts/mpass b/bin/menuscripts/mpass
deleted file mode 100755
index 8d5f4eb..0000000
--- a/bin/menuscripts/mpass
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env sh
-store="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
-
-# list passwords, group directories first
-list_pswds()
-{
- find "$1" \
- -maxdepth 1 -mindepth 1 \
- -not -name '.*' -type d -printf "%y\t%f\n" -o \
- -not -name '.*' -not -type d -printf "%y\t%f\n" |
- sort -k1 -k2 |
- cut -f 2 | sed 's/\.gpg$//'
-}
-
-while [ -d "$store/$file" ]
-do
- choice="$(list_pswds "$store/$file" | commander -c -d)"
- [ "$choice" ] || exit 1
- [ -z "$file" ] && file="$choice" || file="$file/$choice"
-done
-[ "$file" ] || exit 1
-
-pass show -c "$file" || exit 1
-notify-send -t 1000 "mpass" "copied <b>$file</b>"
-
-[ "$WAYLAND_DISPLAY" ] && cliphist list >/dev/null && # on wayland and cliphist is running
- cliphist list | head -n 1 | cliphist delete
diff --git a/config/X/x11/xinitrc b/config/X/x11/xinitrc
index 5f595b1..4eb34ed 100755
--- a/config/X/x11/xinitrc
+++ b/config/X/x11/xinitrc
@@ -19,6 +19,7 @@ if [ -d /etc/X11/xinit/xinitrc.d ] ; then
fi
export MENUCMD="dmenu"
+export IMAGE="feh"
xcompmgr &
feh --no-fehbg --bg-scale ~/pics/wallpaper
setxkbmap -option ctrl:nocaps
diff --git a/config/home/.zshenv b/config/home/.zshenv
index 6edfce8..32c92f4 100644
--- a/config/home/.zshenv
+++ b/config/home/.zshenv
@@ -3,6 +3,8 @@ export EDITOR="nvim"
export VISUAL="nvim"
export BROWSER="firefox"
+export VIEWER="zathura"
+export PLAYER="mpv"
export XDG_CONFIG_HOME="$HOME"/.config
export XDG_CACHE_HOME="$HOME"/.cache
diff --git a/config/hyprland/hypr/env.conf b/config/hyprland/hypr/env.conf
index f7ff6b9..5c4f56a 100644
--- a/config/hyprland/hypr/env.conf
+++ b/config/hyprland/hypr/env.conf
@@ -28,6 +28,7 @@ env = CLUTTER_BACKEND,wayland
env = TERMINAL,foot
env = MENUCMD,tofi
+env = IMAGE,imv
# # nvidia
# env = LIBVA_DRIVER_NAME,nvidia