Skip to content

Commit

Permalink
📅 Monthly update: New script for proper updating of Arch Linux, modif…
Browse files Browse the repository at this point in the history
…ications for some scripts and key configs for neovim
  • Loading branch information
SamIsTheFBI committed Jun 1, 2023
1 parent 0e67a3d commit d465fda
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .config/nvim/lua/ricing/whichkey.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local mappings = {
q = { ":q<CR>", "Quit" },
Q = { ":q!<CR>", "Force quit" },
gc = { ":!gcc -o a \"%\" -lm<CR>", "Compile C code" },
gp = { ":!g++ -fsanitize=address -std=gnu++20 -O2 -Wall \"%\" -o a<CR>", "Compile C++ code" },
gp = { ":!g++ -fsanitize=address -std=gnu++20 -O2 -Wall -lncurses \"%\" -o a<CR>", "Compile C++ code" },
tc = { ":ColorizerToggle<CR>", "Toggle Colorizer" },
tw = { ":set wrap!<CR>", "Toggle word wrap" },
td = { "wbi\"<ESC>wea\"<ESC>", "Add double quotes around current word" },
Expand Down
3 changes: 3 additions & 0 deletions .config/zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ sd() {
# Set shell options: http://zsh.sourceforge.net/Doc/Release/Options.html.
setopt glob_dots # no special treatment for file names with a leading dot
setopt no_auto_menu # require an extra TAB press to open the completion menu

TODO_LIST_PATH=${HOME}/Documents/todo.txt
[ -f ${TODO_LIST_PATH} ] && cat "${TODO_LIST_PATH}"
16 changes: 12 additions & 4 deletions .local/bin/nettraf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

[ -z "${TERMINAL}" ] && TERMINAL="st"

SBAR_VAL="${XDG_CONFIG_HOME:-${HOME}/.config}/sbar_network"

[ ! -f "${SBAR_VAL}" ] && touch "${SBAR_VAL}"

notify () {
notify-send -a "nettraf" -r 415178 -t 3000 "${n_glyph}" "<span font = 'JetBrainsMono Nerd Font 11'>$1</span>" 2>/dev/null
}
Expand Down Expand Up @@ -41,7 +45,7 @@ net () {
}

name () {
[ ${internet} -gt 0 ] && echo -e "${n_glyph} $(nmcli -t -f NAME connection show --active)" || echo " Disconnected"
[ ${internet} -gt 0 ] && echo -e "${n_glyph} $(nmcli -t -f NAME connection show --active | sed -n 1p)" || echo " Disconnected"
}

sbar_output () {
Expand All @@ -55,15 +59,19 @@ norm_output () {
check_internet
check_network_interface

[ "${1}" == 'sbar' ] && sbar_value="$(cat "${SBAR_VAL}" | sed -n 1p)"

case $BLOCK_BUTTON in
1) [ ${internet} -gt 0 ] \
1) [ "${sbar_value}" == 'name' ] && echo "net" > "${SBAR_VAL}" || echo "name" > "${SBAR_VAL}" ;;
2) [ ${internet} -gt 0 ] \
&& notify "Connected to $(name)<br>$(ifconfig wlo1 | grep 'inet' | sed -n 1p | awk '{print $1 " " $2}')" \
|| notify " Disconnected" ;;
3) ${TERMINAL} -e nmtui 2>/dev/null ;;
3) ${TERMINAL} -e nmtui 2>/dev/null ;;
esac


case "${1}" in
'sbar') sbar_output "$(net)" ;;
'sbar') [ "${sbar_value}" == 'net' ] && sbar_output "$(net)" || sbar_output "$(name)" ;;
'name') norm_output "$(name)" ;;
'' | *) norm_output "$(net)" ;;
esac
26 changes: 13 additions & 13 deletions .local/bin/playt
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ ytdlp_best_audio () {
check_dir "${musicdl}"
cd "${musicdl}"

logger "Checking if already available..."
notify "Checking if already available..."

name="$(yt-dlp --print "%(title)s." "$url")"
[ -e "${musicdl}/$name"* ] && check_dl "${musicdl}" && return 0 || notify "Good to go"
# logger "Checking if already available..."
# notify "Checking if already available..."
#
# name="$(yt-dlp --print "%(title)s." "$url")"
# [ -e "${musicdl}/$name"* ] && check_dl "${musicdl}" && return 0 || notify "Good to go"

notify "Trying to download..."
st -e yt-dlp -f 'ba' \
st -e yt-dlp -ciw -f 'ba' \
-x --audio-format mp3 \
--embed-thumbnail \
$url \
Expand All @@ -98,11 +98,11 @@ ytdlp_audio_video () {
check_dir "${videodl}"
cd "${videodl}"

logger "Checking if already available..."
notify "Checking if already available..."

name="$(yt-dlp --print "%(title)s [%(id)s]." "$url")"
[ -e "${videodl}/$name"* ] && check_dl "${videodl}" && return 0 || notify "Good to go"
# logger "Checking if already available..."
# notify "Checking if already available..."
#
# name="$(yt-dlp --print "%(title)s [%(id)s]." "$url")"
# [ -e "${videodl}/$name"* ] && check_dl "${videodl}" && return 0 || notify "Good to go"
# name="$(yt-dlp --print "%(uploader)s/%(playlist)s" "$url")"
# [ -e "${videodl}/$name"* ] && check_output "${videodl}" && return 0 || notify "Good to go"

Expand All @@ -122,7 +122,7 @@ ytdlp_audio_video () {
*youtube*playlist?list=*)
echo "URL Type: YT Playlist"
st -e \
yt-dlp -f $format \
yt-dlp -ciw -f $format \
--embed-thumbnail \
--convert-subs srt \
--embed-sub \
Expand All @@ -136,7 +136,7 @@ ytdlp_audio_video () {
*)
echo "URL Type: Video"
st -e \
yt-dlp -f $format \
yt-dlp -ciw -f $format \
--embed-thumbnail \
--convert-subs srt \
--embed-sub \
Expand Down
44 changes: 44 additions & 0 deletions .local/bin/update-arch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

PKG="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/packages.txt"
RETRY="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/retry.txt"
DED="${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch/problem-packages.txt"

rm -rf "${PKG}" "${RETRY}" "${DED}"
space_left=$(df /home/ --output=avail | grep "[0-9]")

[ ${space_left} == 0 ] && echo -e "No space available for update!" && exit

[ ! -d "${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch" ] && mkdir -p "${XDG_CONFIG_HOME:-${HOME}/.config}/update-arch"
pacman -Qu | awk -F ' ' '{print $1}' >> "${PKG}"

# echo "Please write your password. It will be needed to run sudo to update your system"
# read password
echo ${password} | sudo pacman -Sy --noconfirm --needed archlinux-keyring

pages=1
while [[ ${pages} != 0 && ${space_left} != 0 ]]; do
echo ${password} | sudo pacman -Sy --noconfirm --needed $(cat "${PKG}" | sed -n 1p)
[ $(echo $?) != 0 ] && echo -e $(cat "${PKG}" | sed -n 1p) >> "${RETRY}"
sed -i '1d' "${PKG}"
pages=$(cat "${PKG}" | wc -l)
space_left=$(df /home/ --output=avail | grep "[0-9]")
done

[ ${space_left} == 0 ] && echo -e "No space available for update!" && exit

pages=$(cat "${RETRY}" | wc -l)
while [[ ${pages} != 0 && ${space_left} != 0 ]]; do
echo ${password} | sudo pacman -Sy --noconfirm --needed $(cat "${RETRY}" | sed -n 1p)
[ $(echo $?) != 0 ] && echo -e $(cat "${RETRY}" | sed -n 1p) >> "${DED}"
sed -i '1d' "${RETRY}"
pages=$(cat "${RETRY}" | wc -l)
space_left=$(df /home/ --output=avail | grep "[0-9]")
done

[ ${space_left} == 0 ] && echo -e "No space available for update!" && exit

pages=$(cat "${DED}" | wc -l)
if [ ${pages} != 0 ]; then
echo -e "Some packages were not updated due to some issues. Please check ${DED}. You may download & install them manually"
fi

0 comments on commit d465fda

Please sign in to comment.