Agregar unos nuevos y borrar unos viejos

This commit is contained in:
deadguy 2023-03-21 00:28:54 -03:00
parent 339cb3de0b
commit 3e9f725a07
Signed by: dgy
GPG Key ID: 37CA55B52CF63730
8 changed files with 45 additions and 231 deletions

12
barrita
View File

@ -1,11 +1,11 @@
#!/bin/sh
if [ -z "$(pgrep -x polybar)" ]; then
BAR="LaBarra"
for m in $(polybar --list-monitors | cut -d":" -f1); do
MONITOR=$m polybar --reload $BAR &
sleep 1
done
# for m in $(polybar --list-monitors | cut -d":" -f1); do
# MONITOR=$m polybar --reload LaBarra &
# sleep 1
# done
polybar --reload LaBarra &
else
polybar-msg cmd restart
polybar-msg cmd restart
fi

10
cartero
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
pgrep -x mbsync > /dev/null && exit
ping -q -c 1 1.1.1.1 > /dev/null || exit
pgrep -x mbsync >/dev/null && exit
ping -q -c 1 1.1.1.1 >/dev/null || exit
DATA="${XDG_DATA_HOME:-$HOME/.local/share}"
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
@ -11,7 +11,7 @@ ICON="$HOME/img/.icn/App_Mail.svg"
syncandnotify() {
acc="$(echo "$account" | sed "s/.*\///")"
mbsync -c "$CONFIG"/isync/mbsyncrc "$acc"
new=$(find "$DATA/mail/$acc/INBOX/new/" "$DATA/mail/$acc/Inbox/new/" "$DATA/mail/$acc/inbox/new/" -type f -newer "$CONFIG/neomutt/.mailsynclastrun" 2> /dev/null)
new=$(find "$DATA/mail/$acc/INBOX/new/" "$DATA/mail/$acc/Inbox/new/" "$DATA/mail/$acc/inbox/new/" -type f -newer "$CONFIG/neomutt/.mailsynclastrun" 2>/dev/null)
newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l)
if [ "$newcount" -gt "0" ]; then
for file in $new; do
@ -19,7 +19,7 @@ syncandnotify() {
from=$(awk '/^From: / && ++n ==1,/^\<.*\>:/' "$file" | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | awk '{ $1=""; if (NF>=3)$NF=""; print $0 }' | sed 's/^[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//')
subject=$(awk '/^Subject: / && ++n == 1,/^\<.*\>: / && ++i == 2' "$file" | head -n-1 | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | sed 's/^Subject: //' | sed 's/^{[[:blank:]]*[\"'\''\<]*//;s/[\"'\''\>]*[[:blank:]]*$//' | tr -d '\n')
if [ -n $DISPLAY ]; then
if [ -n "$DISPLAY" ]; then
notify-send --app-name="neomutt" -i "$ICON" "Mensaje nuevo para $acc" "$from: $subject" &
fi
done
@ -40,6 +40,6 @@ for account in $accounts; do
done
wait
notmuch new 2> /dev/null
notmuch new 2>/dev/null
touch "$CONFIG/neomutt/.mailsynclastrun"

181
labarra
View File

@ -1,181 +0,0 @@
#!/bin/bash
# original file at https://gitlab.com/protesilaos/cpdfd/-/blob/master/bin/bin/melonpanel
# Kill any running lemonbar
pgrep -x lemonbar > /dev/null && pkill -x lemonbar
get_xrdb() {
xrdb -query | awk -v pat="$1" '$0~pat {print $2}'
}
background="$(get_xrdb background)"
foreground="$(get_xrdb color7)"
foregroundalt="$(get_xrdb color8)"
color1="$(get_xrdb color11)"
color2="$(get_xrdb color3)"
color3="$(get_xrdb color9)"
colormail="$(get_xrdb color13)"
colorwifi="$(get_xrdb color12)"
colorfecha="$(get_xrdb color10)"
colorhora="$(get_xrdb color14)"
panel_height=22
fontmain='System Charcoal:style=regular:size=11'
fontbold='System Charcoal:style=bold:size=11'
fonticon='JetBrainsMono Nerd Font:style=regular:size=11'
# Panel modules
# -------------
#
# NOTE all functions that are meant to pipe their output to the panel
# will echo a majuscule (letter A-Z). This is done to easily retrieve
# their output from the named pipe. The letter has to be unique and,
# ideally, use common words that denote the function of the content of
# the command such as e.g. D for Date, N for Network... Where this
# would lead to conflicts, find a synonym or something close enough.
#
# The various sequences %{..} are part of lemonbar's syntax for styling
# the output. See `man lemonbar`.
_mail() {
mail_label=''
unread="$(find "$XDG_DATA_HOME"/mail/*/[Ii][Nn][Bb][Oo][Xx]/new/* -type f | wc -l 2>/dev/null)"
if [ "$unread" -gt 0 ]; then
echo -n "%{F$colormail}$mail_label $unread%{F-} "
fi
}
_wifi() {
wifi_label=''
if [ "$(cat /sys/class/net/w*/operstate)" = up ]; then
net="$(awk '/^\s*w/ { print int($3 * 100 / 70) }' /proc/net/wireless)"
echo -n "%{F$colorwifi}$wifi_label $net%{F-} "
fi
}
_datetime() {
fecha=$(date "+%a %d %R")
echo -n "%{F$colorfecha}$fecha%{F-} "
}
# Include all modules in a single infinite loop
_modules() {
while true; do
echo "M" "$(_mail)"
echo "N" "$(_wifi)"
echo "D" "$(_datetime)"
sleep 15s
done
}
# Piping and reading the output of the modules
# --------------------------------------------
# set path to named pipe used to store process data for these operations
panel_fifo='/tmp/panel.fifo'
# make sure you delete any existing named pipe
[ -e "$panel_fifo" ] && rm "$panel_fifo"
# create a new named pipe
mkfifo "$panel_fifo"
# pipe the output of the modules to the fifo
_modules > "$panel_fifo" &
bspc subscribe report > "$panel_fifo" &
# Read the content of the fifo file. We differentiate between modules
# based on the majuscule (letter A-Z) they piped into melonpanel_fifo
# (see modules above). Here we just add a shorter variable to each
# module, which helps position it on the panel (the last printf).
_panel() {
while read -r line ; do
case $line in
M*) mail="${line#?}" ;;
N*) wifi="${line#?}" ;;
D*) datetime="${line#?}" ;;
W*)
# bspwm's state
wm=
IFS=':'
set -- ${line#?}
while [ "$#" -gt 0 ] ; do
item="$1"
name="${item#?}"
case "$item" in
[mMfFoOuU]*)
case "$item" in
m*)
# monitor
FG="$foregroundalt" # needed to avoid invalid colour error
on_focused_monitor=
name=
;;
M*)
# focused monitor
FG="$foregroundalt" # needed to avoid invalid colour error
on_focused_monitor=1
name=
;;
# {Free,Occupied,Urgent} focused
[FOU]*)
if [ -n "$on_focused_monitor" ]; then
FG="$color1"
name="%{T2}${name/*/[$name]}%{T-}" # the %{Tx} specifies the bold font
else
FG="$color2"
name="${name/*/ $name^}"
fi
;;
# {free,occupied,urgent} unfocused
f*)
FG="$foreground"
name="${name/*/ $name }"
;;
o*)
FG="$color2"
name="${name/*/ $name^}"
;;
u*)
FG="$color3"
name="${name/*/ $name!}"
;;
esac
wm="${wm}%{F$FG}${name}%{F-} "
;;
esac
shift
done
esac
_panel_layout() {
echo "%{r} $mail $wifi $datetime $wm"
}
echo "%{Sf}$(_panel_layout) %{Sl}$(_panel_layout)"
done
}
# Launch the panel with the given parameters
# ------------------------------------------
# NOTE the syntax for the background value. If you want transparency,
# just replace "ff" with a lower value: "00" means no opacity. This is
# hexadecimal notation: 0-9, a-f, A-F.
_panel < "$panel_fifo" | lemonbar -u 2 -p -g "x${panel_height}" \
-F "$foreground" -B "#CC${background:1}" -f "$fontmain" -f "$fontbold" -f "$fonticon" -n "LaBarra" &
# Hide panel when windows are in full screen mode. This does not work
# all the time, especially with lower `sleep` values, requiring a
# re-launch of melonpanel (pkill -x melonpanel && melonpanel). I have
# yet to find a robust solution.
#
# Source of this snippet (with minor adapatations by me):
# https://github.com/baskerville/bspwm/issues/484
until bar_id=$(xdo id -a 'LaBarra'); do
sleep 1s
done
xdo below -t $(xdo id -n root) $bar_id &

3
luals
View File

@ -1,3 +0,0 @@
#!/bin/sh
exec "/mnt/wd1tb/catacombs/code/lua-language-server/bin/lua-language-server" "$@"

32
nsxiv-url Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env sh
cache_dir="${TMPDIR:-/tmp}/nsxiv"
die() {
[ -n "$1" ] && printf '%s\n' "$*" >&2
exit 1
}
cleanup() {
rm -f -- "$cache_dir"/*
}
get_image() (
cd "$cache_dir" && curl -sSLO "$1"
)
### main ###
[ -z "$1" ] && die "No arguments given"
trap cleanup EXIT
[ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die
while [ -n "$1" ]; do
case "$1" in
*://*.*) get_image "$1" ;;
*) echo "Invalid url: $1" >&2 ;;
esac
shift
done
[ "$(find "$cache_dir" -type f -print | wc -l)" -ne 0 ] &&
nsxiv -ap "$cache_dir"

2
vix
View File

@ -1,3 +1,3 @@
#!/bin/sh
tmux split-window -h "$EDITOR \"$*\"" &
tmux split-window -hl 95 "$EDITOR \"$*\""

2
ytp
View File

@ -1,4 +1,4 @@
#!/bin/sh
# Description: download all videos from a playlist in a separate directory.
yt-dlp -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' "$@"
yt-dlp --add-metadata --no-youtube-include-dash-manifest -i --no-cache-dir --geo-bypass -o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s' "$@"

34
zu
View File

@ -1,34 +0,0 @@
#!/bin/sh
archive="$(readlink -f "$*")" &&
directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" &&
mkdir -p "$directory" &&
cd "$directory" || exit
[ "$archive" = "" ] && printf "Give archive to extract as argument.\\n" && exit
if [ -f "$archive" ]; then
case "$archive" in
*.tar.bz2 | *.tbz2) tar xvjf "$archive" ;;
*.tar.xz | *.txz) tar -xvJf "$archive" ;;
*.tar.gz | *.tgz) tar xvzf "$archive" ;;
*.tar.zst) tar --zstd -xvf "$archive" ;;
*.tar.lz) tar --lzip -xvf "$archive" ;;
*.lzma) unlzma "$archive" ;;
*.bz2) bunzip2 "$archive" ;;
*.rar) unrar x -ad "$archive" ;;
*.gz) gunzip "$archive" ;;
*.tar) tar xvf "$archive" ;;
*.zip | *.ZIP | *.cbz) unzip "$archive" ;;
*.zstd) unzstd "$archive" ;;
*.Z) uncompress "$archive" ;;
*.7z) 7z x "$archive" ;;
*.xz) unxz "$archive" ;;
*.deb | *.ar) ar -x "$archive" ;;
*.rpm) 7z x "$archive" ;;
*.exe) cabextract "$archive" ;;
*) printf "extract: '%s' - unknown archive method\\n" "$archive" ;;
esac
else
printf "File \"%s\" not found.\\n" "$archive"
fi