refactor!: switch to dendritic pattern
BREAKING CHANGE: complete reorganization of the repository
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "askpass" ''
|
||||
${pkgs.rofi}/bin/rofi -dmenu -password -no-fixed-num-lines -p $(printf \"$*\" | sed 's/://')''
|
||||
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "backup" ''
|
||||
cp -r "$1" "$1.bak.$(date +%Y%m%d%H%M%S)"''
|
||||
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "keygen"
|
||||
"tr -cd '[:alnum:]' < /dev/urandom | fold -w 64 | head -n 1 | tr -d '\n'"
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
pkgs.writeShellScriptBin "launch-with-emacsclient" ''
|
||||
filename="$1"
|
||||
line="$2"
|
||||
column="$3"
|
||||
${config.home.dev.editors.emacs.package}/bin/emacsclient +$line:$column "$filename"''
|
||||
@@ -0,0 +1,23 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "app-launcher" ''
|
||||
LOG_FILE="$HOME/.local/share/app-launcher.log"
|
||||
|
||||
logger() {
|
||||
local level="$1"
|
||||
local message="$2"
|
||||
local timestamp
|
||||
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
printf "[%s] [%-7s] %s\n" "$timestamp" "''${level^^}" "$message" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
CAELESTIA_ACTIVE=$(systemctl --user is-active caelestia.service)
|
||||
logger debug "Caelestia activity: $CAELESTIA_ACTIVE"
|
||||
|
||||
if systemctl --user is-active caelestia.service | grep 'active' &> /dev/null ; then
|
||||
logger info "Using Caelestia app launcher"
|
||||
caelestia shell drawers toggle launcher || \
|
||||
logger error "failed to launch Caelestia app launcher"
|
||||
exit 0
|
||||
fi
|
||||
rofi -show drun
|
||||
''
|
||||
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "mp42webm" ''
|
||||
${pkgs.ffmpeg}/bin/ffmpeg -i "$1" -c:v libvpx -crf 10 -b:v 1M -c:a -hwaccel=auto libvorbis "$1".webm''
|
||||
@@ -0,0 +1,40 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "plock" ''
|
||||
LOG_FILE="$HOME/.local/share/plock.log"
|
||||
|
||||
logger() {
|
||||
local level="$1"
|
||||
local message="$2"
|
||||
local timestamp
|
||||
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
printf "[%s] [%-7s] %s\n" "$timestamp" "''${level^^}" "$message" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
CAELESTIA_ACTIVE=$(systemctl --user is-active caelestia.service)
|
||||
logger debug "Caelestia activity: $CAELESTIA_ACTIVE"
|
||||
if systemctl --user is-active caelestia.service | grep 'active' &> /dev/null ; then
|
||||
logger info "locking Caelestia session"
|
||||
caelestia shell lock lock || \
|
||||
logger error "failed to lock Caelestia session"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TMPBG="/tmp/screen.png"
|
||||
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
|
||||
logger info "wayland session detected"
|
||||
SCREENER=${pkgs.grim}/bin/grim
|
||||
LOCKER="${pkgs.swaylock}/bin/swaylock -feF"
|
||||
else
|
||||
logger info "x11 session detected"
|
||||
SCREENER=${pkgs.scrot}/bin/scrot
|
||||
LOCKER="${pkgs.i3lock}/bin/i3lock -ef"
|
||||
fi
|
||||
|
||||
$SCREENER "$TMPBG"
|
||||
logger info "generating lock screen image"
|
||||
${pkgs.corrupter}/bin/corrupter -add 0 "$TMPBG" "$TMPBG" || logger error "failed to generate lock screen image"
|
||||
logger info "locking screen"
|
||||
logger debug "locking screen with command `''${SCREENER}`"
|
||||
$LOCKER -ti "$TMPBG"
|
||||
rm "$TMPBG"
|
||||
''
|
||||
@@ -0,0 +1,56 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "screenshot" ''
|
||||
OUTFILE_BASE="$HOME/Pictures/Screenshots/Screenshot_$(date +%Y-%m-%d_%H.%M.%S)"
|
||||
OUTFILE="$OUTFILE_BASE.png"
|
||||
SUFFIX=0
|
||||
|
||||
while getopts ':cd:egs' OPTION; do
|
||||
case "$OPTION" in
|
||||
c )
|
||||
COPY="yes"
|
||||
;;
|
||||
d )
|
||||
DELAY="$OPTARG"
|
||||
;;
|
||||
e )
|
||||
EDIT="yes"
|
||||
;;
|
||||
g )
|
||||
GIMP="yes"
|
||||
;;
|
||||
s )
|
||||
SELECT="yes"
|
||||
;;
|
||||
? )
|
||||
echo "Usage: $(basename "$0") [-c] [-d DELAY] [-e] [-g] [-s]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$SELECT" = "yes" ]; then
|
||||
AREA="$(${pkgs.slurp}/bin/slurp)"
|
||||
fi
|
||||
|
||||
if [ -n "$DELAY" ]; then
|
||||
sleep "$DELAY"
|
||||
fi
|
||||
|
||||
if [ "$SELECT" = "yes" ]; then
|
||||
${pkgs.grim}/bin/grim -g "$AREA" "$OUTFILE"
|
||||
else
|
||||
${pkgs.grim}/bin/grim "$OUTFILE"
|
||||
fi
|
||||
|
||||
if [ "$EDIT" = "yes" ];then
|
||||
${pkgs.swappy}/bin/swappy -f "$OUTFILE" -o "$OUTFILE"
|
||||
fi
|
||||
|
||||
if [ "$GIMP" = "yes" ]; then
|
||||
${pkgs.gimp}/bin/gimp "$OUTFILE"
|
||||
fi
|
||||
|
||||
if [ "$COPY" = "yes" ]; then
|
||||
${pkgs.wl-clipboard-rs}/bin/wl-copy < "$OUTFILE"
|
||||
fi
|
||||
''
|
||||
@@ -0,0 +1,3 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "sshbind" ''
|
||||
ssh -L "$1:$3:$1" "$2" -N''
|
||||
@@ -0,0 +1,16 @@
|
||||
{pkgs, ...}:
|
||||
pkgs.writeShellScriptBin "ytplay" ''
|
||||
URL=$(rofi -dmenu -i -p "Video URL")
|
||||
if [ -z "$URL" ]; then
|
||||
echo "You need to provide a URL"
|
||||
exit 1
|
||||
fi
|
||||
RESOLUTION_CHOICE=$(${pkgs.yt-dlp}/bin/yt-dlp --list-formats "$URL" | \
|
||||
grep -E "webm.*[0-9]+x[0-9]" | \
|
||||
awk '{print $3 " " $1}' | \
|
||||
sort -gu | \
|
||||
rofi -dmenu -i -p "Resolution")
|
||||
mapfile -t RESOLUTION <<< "$RESOLUTION_CHOICE"
|
||||
RESOLUTION_CODE=''${RESOLUTION[0]}
|
||||
${pkgs.mpv}/bin/mpv --ytdl-format="''${RESOLUTION_CODE}+bestaudio/best" "$URL"
|
||||
''
|
||||
Reference in New Issue
Block a user