big overhaul on shell scripts
This commit is contained in:
parent
0387d297e5
commit
4788723680
26 changed files with 69 additions and 512 deletions
|
@ -57,6 +57,8 @@ case "$(printf "%s\n" "$(readlink -f "$1")" | awk '{print tolower($0)}')" in
|
|||
# image "$CACHE" "$2" "$3" "$4" "$5"
|
||||
# ;;
|
||||
*.ttf|*.otf|*.woff)
|
||||
# xc: background color, pointsize: font size, font: input file, fill: foreground color, annotate: preview text, flatten: output file
|
||||
convert -size "532x365" xc:"#ffffff" -gravity center -pointsize 38 -font "$1" -fill "#000000" -annotate +0+0 "ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n1234567890\n!@$\%(){}[]" -flatten "$2"
|
||||
fontpreview -i "$1" -o "${CACHE}.jpg"
|
||||
image "${CACHE}.jpg" "$2" "$3" "$4" "$5"
|
||||
;;
|
||||
|
|
|
@ -10,8 +10,8 @@ on-touch=dismiss
|
|||
|
||||
# STYLE OPTIONS
|
||||
font=Monaspice Kr Nerd Font 12
|
||||
width=300
|
||||
height=100
|
||||
width=750
|
||||
height=750
|
||||
margin=10
|
||||
padding=10
|
||||
border-size=1
|
||||
|
|
|
@ -22,14 +22,15 @@ alias vw="$EDITOR ~/.nky/Coding/Markdown/wiki/Todo.md"
|
|||
alias vim="$EDITOR"
|
||||
alias p="sudo pacman"
|
||||
alias sd="shutdown now"
|
||||
alias rb="sudo reboot"
|
||||
alias nf="neofetch"
|
||||
alias cpc="cleansystem"
|
||||
alias rmpkg="sudo pacman -Rcns"
|
||||
alias rmpkg-conf="sudo pacman -Runs"
|
||||
alias codingsize="ncdu ~/.nky/Coding --exclude .git --exclude image --exclude node_modules --exclude jnic.zip --exclude 'Machine Learning-A-Z-Codes-Datasets.zip'"
|
||||
alias foldersize="sudo du -shc"
|
||||
alias findfiles="grep --exclude-dir={.mozilla,.cache,share,dump,env,state,node_modules,pdfs,build,.git,npm,autojump,cargo,gnupg,zsh-autosuggestions,zsh-syntax-highlighting,zsh-history-substring-search,.wakatime} --exclude=.zcompdump --exclude=.git --exclude=.sh_history -rnwinRIH . -e"
|
||||
alias homefiles="find ~ -type d \( -path ~/.cargo -o -path ~/.local/share -o -path ~/.local/state/nvim -o -path ~/.mozilla -o -path ~/.npm -o -path ~/.autojump -o -path ~/.cache -o -path ~/dotfiles -o -path ~/.gnupg -o -path ~/.config/zsh/zsh-syntax-highlighting -o -path ~/.config/zsh/zsh-autosuggestions -o -path ~/.config/zsh/powerlevel10k \) -prune -o -type f -not -path '*/.git/*' -not -path '*/node_modules/*' -print | fnf"
|
||||
alias findfiles="grep --exclude-dir={.mozilla,.cache,share,dump,env,state,node_modules,pdfs,build,.git,npm,autojump,cargo,gnupg,.wakatime} --exclude=.zcompdump --exclude=.git --exclude=.sh_history -rnwinRIH . -e"
|
||||
alias homefiles="find ~ -type d \( -path ~/.cargo -o -path ~/.local/share -o -path ~/.local/state/nvim -o -path ~/.mozilla -o -path ~/.npm -o -path ~/.autojump -o -path ~/.cache -o -path ~/dotfiles -o -path ~/.gnupg \) -prune -o -type f -not -path '*/.git/*' -not -path '*/node_modules/*' -print | fnf"
|
||||
alias gitfolders="find . -type d -name '.git' -not -path '*nvim*' -not -path '*tmux*'"
|
||||
alias convertunix="find . -type f -print0 | xargs -0 dos2unix --"
|
||||
alias hst="history | cut -c 8- | sort | uniq | fnf -l 100 | tr -d '\n' | wl-copy"
|
||||
|
@ -38,14 +39,15 @@ alias lf="lfrun"
|
|||
alias s="sudo systemctl"
|
||||
alias ipv4="echo $(curl -s ipinfo.io/ip)"
|
||||
alias wmenu="wmenu -i -f 'MonaspiceKr Nerd Font 13' -N 1e1e2e -n cdd6f4 -M 1e1e2e -m f38ba8 -S 1e1e2e -s f9e2af -p 'Menu'"
|
||||
alias hp="bluetoothctl power on && bluetoothctl connect '50:DE:06:D7:C7:30' && pactl set-default-sink 'bluez_output.50_DE_06_D7_C7_30.1'"
|
||||
|
||||
# Change directory aliases
|
||||
alias .='cd ~'
|
||||
alias ..='cd ..'
|
||||
|
||||
alias config='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'
|
||||
alias cad='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME add'
|
||||
alias cco='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME commit -m'
|
||||
alias cpu='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME push'
|
||||
alias cst='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME status -u'
|
||||
alias cdf='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME diff'
|
||||
alias cad='config add'
|
||||
alias cco='config commit -m'
|
||||
alias cpu='config push'
|
||||
alias cst='config status -u'
|
||||
alias cdf='config diff'
|
||||
|
|
|
@ -32,4 +32,3 @@ export XDG_SESSION_TYPE=wayland
|
|||
export XDG_SESSION_DESKTOP=wlroots
|
||||
export XCURSOR_SIZE=24
|
||||
export WLR_NO_HARDWARE_CURSORS=1
|
||||
export WLR_RENDERER=gles2
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "${HOME}/.config/sh/env"
|
||||
|
||||
if lsmod | grep -wq "pcspkr"; then
|
||||
sudo rmmod pcspkr # Remove annoying beep sound in tty
|
||||
fi
|
||||
|
||||
if ! pgrep -x "dwl" > /dev/null; then
|
||||
if [[ "$(tty)" == "/dev/tty1" ]] then
|
||||
dwl -s startw # run dwl if not running
|
||||
fi
|
||||
|
||||
|
@ -41,7 +43,25 @@ c() {
|
|||
ccc "$@"
|
||||
cd "$(cat "${XDG_CACHE_HOME}/ccc/.ccc_d")"
|
||||
}
|
||||
man () { section="$(test -z $2 && echo 0 || echo $1)" page="${2:-$1}" ; curl -s "https://man-api.ch/v1/buster/${section}/${page}" | nvimpager; }
|
||||
|
||||
ma() { section="$(test -z $2 && echo 0 || echo $1)" page="${2:-$1}" ; curl -s "https://man-api.ch/v1/buster/${section}/${page}" | nvimpager; }
|
||||
|
||||
manl() {
|
||||
man $(man -k . | awk -F'-' '{print $1}' | awk -F'(' '{ print $1 }' | sed 's/ //' | fnf)
|
||||
}
|
||||
|
||||
webjpeg() {
|
||||
convert $1 -sampling-factor 4:2:0 -strip -quality 75 -interlace JPEG -colorspace sRGB -resize $2 $3
|
||||
}
|
||||
|
||||
replace() {
|
||||
echo "Type the pattern you want to replace"
|
||||
read pattern
|
||||
echo "Type the phrase you want to replace with"
|
||||
read replacewith
|
||||
|
||||
find . -type f -exec sed -i "s/$pattern/$replacewith/g" {} \;
|
||||
}
|
||||
|
||||
bind -x '"\C-f":"lfcd"'
|
||||
bind -x '"\C-o":"cd $(dirname $(find . -name .git -prune -o -type f | fnf))"'
|
||||
|
|
|
@ -21,7 +21,6 @@ sudo pacman -S --needed bluez brightnessctl btop chafa connman dos2unix firefox
|
|||
sudo sed -i 's/MODULES=()/MODULES=(amdgpu nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' /etc/mkinitcpio.conf
|
||||
# sudo sed -i 's/MODULES=()/MODULES=(vfio vfio_iommu_type1 vfio_pci amdgpu nvidia nvidia_modeset nvidia_uvm nvidia_drm)/' /etc/mkinitcpio.conf # for qemu passthrough
|
||||
# sudo sed -i '/^HOOKS=/ s/udev/& plymouth/' /etc/mkinitcpio.conf
|
||||
# add modconf to HOOKS
|
||||
sudo mkinitcpio -p linux --config /etc/mkinitcpio.conf --generate /boot/initramfs-custom.img
|
||||
echo -e "blacklist nouveau\noptions nvidia_drm modeset=1 fbdev=1" | sudo tee -a /etc/modprobe.d/nvidia.conf
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
source $HOME/.config/sh/aliases
|
||||
|
||||
op=$(echo " Poweroff\n Reboot\n Suspend\n Lock\n Logout" | wmenu | awk '{print tolower($2)}')
|
||||
|
||||
case $op in
|
||||
poweroff)
|
||||
exit
|
||||
;;
|
||||
reboot)
|
||||
exit
|
||||
;;
|
||||
suspend)
|
||||
systemctl $op
|
||||
;;
|
||||
lock)
|
||||
swaylock
|
||||
;;
|
||||
logout)
|
||||
hyprctl dispatch exit 0
|
||||
;;
|
||||
esac
|
|
@ -4,5 +4,5 @@ sudo pacman -Rns $(pacman -Qdttq) # remove orphans
|
|||
rm -rf ~/.npm
|
||||
sudo rm -rf /usr/share/doc /usr/share/licenses /usr/share/gtk-doc /usr/lib/node_modules/npm/docs /usr/share/icons/Catppuccin-Mocha-Standard-Lavender-Dark/{gnome-shell,gtk-4.0,cinnamon,gtk-2.0,plank,xfwm4} /usr/share/icons/Catppuccin-Mocha-Standard-Lavender-Dark-{xhpdi,hdpi}/xfwm4
|
||||
|
||||
sudo find / -type f -name "*.md" -print -mount
|
||||
sudo find / -type f -name "LICENSE" -print -mount
|
||||
sudo find / -type f -name "*.md" -delete -mount
|
||||
sudo find / -type f -name "LICENSE" -delete -mount
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Function to count unique packages
|
||||
count_packages() {
|
||||
local package="$1"
|
||||
local count=0
|
||||
|
||||
# Get dependencies recursively using pactree
|
||||
deps=$(pactree -u "$package")
|
||||
|
||||
# Count unique dependencies
|
||||
count=$(echo "$deps" | wc -l)
|
||||
|
||||
echo "$count"
|
||||
}
|
||||
|
||||
# Get all explicitly installed packages and count their dependencies
|
||||
pacman -Qe | awk '{print $1}' | while read -r package; do
|
||||
total_count=$(count_packages "$package")
|
||||
echo "$package: $total_count"
|
||||
done
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
while true; do
|
||||
clear
|
||||
echo $(date +"%T")
|
||||
sleep 1
|
||||
done
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Initialize total count
|
||||
total_lines=0
|
||||
|
||||
# List of files to ignore
|
||||
ignore_files=(
|
||||
"*/.git/*"
|
||||
"*.log"
|
||||
"*/LICENSE"
|
||||
"*.gitattributes"
|
||||
"*.vcxproj*"
|
||||
"*.sln"
|
||||
"*.gitignore"
|
||||
"*.md"
|
||||
"*.o"
|
||||
"*.tar.gz"
|
||||
"*/Makefile"
|
||||
"*.1"
|
||||
"*.xml"
|
||||
"*.iml"
|
||||
"*.yml"
|
||||
"*.jar"
|
||||
"*.jpg"
|
||||
"*.png"
|
||||
"*.json"
|
||||
"*.zip"
|
||||
"*/gradlew"
|
||||
"*.xcf"
|
||||
"*.sxcu"
|
||||
"*.rc"
|
||||
"*.txt"
|
||||
"*/Java/Utilities/*"
|
||||
"*/cath-docs/*"
|
||||
"*.ttf"
|
||||
"*.woff2"
|
||||
"*.exe"
|
||||
"*/SkySkipped/*"
|
||||
"*/master-ghosterbuster-9000/*"
|
||||
"*/lib/json/*"
|
||||
"*/node_modules/*"
|
||||
"*/package.json"
|
||||
"*/package-lock.json"
|
||||
"*/Windows/*"
|
||||
)
|
||||
|
||||
for file in $(find . -type f); do
|
||||
# check if file is directory
|
||||
if [[ -d $file ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if the file is executable
|
||||
if [[ -x $file ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
for ignore in "${ignore_files[@]}"; do
|
||||
if [[ $file == $ignore ]]; then
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
lines=$(wc -l < "$file")
|
||||
total_lines=$((total_lines + lines))
|
||||
done
|
||||
|
||||
echo "Total lines: $total_lines"
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
man $(man -k . | awk -F'-' '{print $1}' | awk -F'(' '{ print $1 }' | sed 's/ //' | fnf)
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
yt-dlp --flat-playlist --get-title $1 > playlist.txt
|
||||
|
||||
hk=$(ls "$HOME/.nky/Music/HK")
|
||||
kr=$(ls "$HOME/.nky/Music/KR")
|
||||
tw=$(ls "$HOME/.nky/Music/TW")
|
||||
jp=$(ls "$HOME/.nky/Music/JP")
|
||||
|
||||
all_songs=($hk $kr $tw $jp)
|
||||
|
||||
while read song; do
|
||||
if [[ ! " ${all_songs[@]} " =~ " ${song}" ]]; then
|
||||
echo "$song"
|
||||
fi
|
||||
done < playlist.txt
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Type the pattern you want to replace"
|
||||
read pattern
|
||||
echo "Type the phrase you want to replace with"
|
||||
read replacewith
|
||||
|
||||
find . -type f -exec sed -i "s/$pattern/$replacewith/g" {} \;
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
convert $1 -sampling-factor 4:2:0 -strip -quality 75 -interlace JPEG -colorspace sRGB -resize $2 $3
|
|
@ -1,244 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Siddharth Dushantha 2020
|
||||
#
|
||||
# Dependencies: sxiv, imagemagick, xdotool, fzf
|
||||
|
||||
VERSION=1.0.7
|
||||
|
||||
# Default values
|
||||
SEARCH_PROMPT="❯ "
|
||||
SIZE=532x365
|
||||
POSITION="+0+0"
|
||||
FONT_SIZE=38
|
||||
BG_COLOR="#ffffff"
|
||||
FG_COLOR="#000000"
|
||||
PREVIEW_TEXT="ABCDEFGHIJKLM\nNOPQRSTUVWXYZ\nabcdefghijklm\nnopqrstuvwxyz\n1234567890\n!@$\%(){}[]"
|
||||
|
||||
show_help() {
|
||||
printf "%s" "\
|
||||
usage: fontpreview [-h] [--size \"px\"] [--position \"+x+y\"] [--search-prompt SEARCH_PROMPT]
|
||||
[--font-size \"FONT_SIZE\"] [--bg-color \"BG_COLOR\"] [--fg-color \"FG_COLOR\"]
|
||||
[--preview-text \"PREVIEW_TEXT\"] [-i font.otf] [-o preview.png] [--version]
|
||||
|
||||
┌─┐┌─┐┌┐┌┌┬┐┌─┐┬─┐┌─┐┬ ┬┬┌─┐┬ ┬
|
||||
├┤ │ ││││ │ ├─┘├┬┘├┤ └┐┌┘│├┤ │││
|
||||
└ └─┘┘└┘ ┴ ┴ ┴└─└─┘ └┘ ┴└─┘└┴┘
|
||||
Very customizable and minimal font previewer written in bash
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-i, --input filename of the input font (.otf, .ttf, .woff are supported)
|
||||
-o, --output filename of the output preview image (input.png if not set)
|
||||
--size size of the font preview window
|
||||
--position the position where the font preview window should be displayed
|
||||
--search-prompt input prompt of fuzzy searcher
|
||||
--font-size font size
|
||||
--bg-color background color of the font preview window
|
||||
--fg-color foreground color of the font preview window
|
||||
--preview-text preview text that should be displayed in the font preview window
|
||||
--version show the version of fontpreview you are using
|
||||
"
|
||||
}
|
||||
|
||||
pre_exit() {
|
||||
# Get the proccess ID of this script and kill it.
|
||||
# We are dumping the output of kill to /dev/null
|
||||
# because if the user quits sxiv before they
|
||||
# exit this script, an error will be shown
|
||||
# from kill and we dont want that
|
||||
kill -9 "$(cat "$PIDFILE" 2>/dev/null)" &> /dev/null
|
||||
|
||||
# Delete tempfiles, so we don't leave useless files behind.
|
||||
rm -rf "$FONTPREVIEW_DIR"
|
||||
}
|
||||
|
||||
generate_preview(){
|
||||
# Credits: https://bit.ly/2UvLVhM
|
||||
convert -size $SIZE xc:"$BG_COLOR" \
|
||||
-gravity center \
|
||||
-pointsize $FONT_SIZE \
|
||||
-font "$1" \
|
||||
-fill "$FG_COLOR" \
|
||||
-annotate +0+0 "$PREVIEW_TEXT" \
|
||||
-flatten "$2"
|
||||
}
|
||||
|
||||
main(){
|
||||
# Checkig if needed dependencies are installed
|
||||
dependencies=(xdotool sxiv convert fzf)
|
||||
for dependency in "${dependencies[@]}"; do
|
||||
type -p "$dependency" &>/dev/null || {
|
||||
echo "error: Could not find '${dependency}', is it installed?" >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
|
||||
# Checking for enviornment variables which the user might have set.
|
||||
# This config file for fontpreview is pretty much the bashrc, zshrc, etc
|
||||
# Majority of the variables in fontpreview can changed using the enviornment variables
|
||||
# and this makes fontpreview very customizable
|
||||
[[ $FONTPREVIEW_SEARCH_PROMPT != "" ]] && SEARCH_PROMPT=$FONTPREVIEW_SEARCH_PROMPT
|
||||
[[ $FONTPREVIEW_SIZE != "" ]] && SIZE=$FONTPREVIEW_SIZE
|
||||
[[ $FONTPREVIEW_POSITION != "" ]] && POSITION=$FONTPREVIEW_POSITION
|
||||
[[ $FONTPREVIEW_FONT_SIZE != "" ]] && FONT_SIZE=$FONTPREVIEW_FONT_SIZE
|
||||
[[ $FONTPREVIEW_BG_COLOR != "" ]] && BG_COLOR=$FONTPREVIEW_BG_COLOR
|
||||
[[ $FONTPREVIEW_FG_COLOR != "" ]] && FG_COLOR=$FONTPREVIEW_FG_COLOR
|
||||
[[ $FONTPREVIEW_PREVIEW_TEXT != "" ]] && PREVIEW_TEXT=$FONTPREVIEW_PREVIEW_TEXT
|
||||
|
||||
# Save the window ID of the terminal window fontpreview is executed in.
|
||||
# This is so that when we open up sxiv, we can change the focus back to
|
||||
# the terminal window, so that the user can search for the fonts without
|
||||
# having to manualy change the focus back to the terminal.
|
||||
xdotool getactivewindow > "$TERMWIN_IDFILE"
|
||||
|
||||
# Flag to run some commands only once in the loop
|
||||
FIRST_RUN=true
|
||||
|
||||
while true; do
|
||||
# List out all the fonts which imagemagick is able to find, extract
|
||||
# the font names and then pass them to fzf
|
||||
font=$(convert -list font | awk -F: '/^[ ]*Font: /{print substr($NF,2)}' | fzf --prompt="$SEARCH_PROMPT")
|
||||
|
||||
# Exit if nothing is returned by fzf, which also means that the user
|
||||
# has pressed [ESCAPE]
|
||||
[[ -z $font ]] && return
|
||||
|
||||
generate_preview "$font" "$FONT_PREVIEW"
|
||||
|
||||
if [[ $FIRST_RUN == true ]]; then
|
||||
FIRST_RUN=false
|
||||
|
||||
# Display the font preview using sxiv
|
||||
#sxiv -g "$SIZE$POSITION" "$FONT_PREVIEW" -N "fontpreview" -b &
|
||||
sxiv -N "fontpreview" -b -g "$SIZE$POSITION" "$FONT_PREVIEW" &
|
||||
|
||||
# Change focus from sxiv, back to the terminal window
|
||||
# so that user can continue to search for fonts without
|
||||
# having to manually change focus back to the terminal window
|
||||
xdotool windowfocus "$(cat "$TERMWIN_IDFILE")"
|
||||
|
||||
# Save the process ID so that we can kill
|
||||
# sxiv when the user exits the script
|
||||
echo $! >"$PIDFILE"
|
||||
|
||||
# Check for crashes of sxiv
|
||||
elif [[ -f $PIDFILE ]] ; then
|
||||
if ! pgrep -F "$PIDFILE" >/dev/null 2>&1; then
|
||||
echo "Restart sxiv - You maybe using a obsolete version. " >&2
|
||||
# Display the font preview using sxiv
|
||||
sxiv -g "$SIZE$POSITION" -N "fontpreview" -b "$FONT_PREVIEW" &
|
||||
|
||||
# Change focus from sxiv, back to the terminal window
|
||||
# so that user can continue to search for fonts without
|
||||
# having to manually change focus back to the terminal window
|
||||
xdotool windowfocus "$(cat "$TERMWIN_IDFILE")"
|
||||
|
||||
# Save the process ID so that we can kill
|
||||
# sxiv when the user exits the script
|
||||
echo $! >"$PIDFILE"
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Disable CTRL-Z because if we allowed this key press,
|
||||
# then the script would exit but, sxiv would still be
|
||||
# running
|
||||
trap "" SIGTSTP
|
||||
|
||||
trap pre_exit EXIT
|
||||
|
||||
# Use mktemp to create a temporary directory that won't
|
||||
# collide with temporary files of other application.
|
||||
FONTPREVIEW_DIR="$(mktemp -d "${TMPDIR:-/tmp}/fontpreview_dir.XXXXXXXX")" || exit
|
||||
PIDFILE="$FONTPREVIEW_DIR/fontpreview.pid"
|
||||
touch "$PIDFILE" || exit
|
||||
FONT_PREVIEW="$FONTPREVIEW_DIR/fontpreview.png"
|
||||
touch "$FONT_PREVIEW" || exit
|
||||
TERMWIN_IDFILE="$FONTPREVIEW_DIR/fontpreview.termpid"
|
||||
touch "$TERMWIN_IDFILE" || exit
|
||||
|
||||
font=$1
|
||||
|
||||
|
||||
# Parse the arguments
|
||||
options=$(getopt -o hi:o: --long position:,size:,version,search-prompt:,font-size:,bg-color:,fg-color:,preview-text:,input:,output:,help -- "$@")
|
||||
eval set -- "$options"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--size)
|
||||
shift
|
||||
FONTPREVIEW_SIZE=$2
|
||||
;;
|
||||
--position)
|
||||
shift
|
||||
FONTPREVIEW_POSITION=$2
|
||||
;;
|
||||
-h|--help)
|
||||
show_help
|
||||
exit
|
||||
;;
|
||||
--version)
|
||||
echo $VERSION
|
||||
exit
|
||||
;;
|
||||
-i|--input)
|
||||
input_file="$2"
|
||||
;;
|
||||
-o|--output)
|
||||
output_file="$2"
|
||||
;;
|
||||
--search-prompt)
|
||||
FONTPREVIEW_SEARCH_PROMPT=$2
|
||||
;;
|
||||
--font-size)
|
||||
FONTPREVIEW_FONT_SIZE=$2
|
||||
;;
|
||||
--bg-color)
|
||||
FONTPREVIEW_BG_COLOR=$2
|
||||
;;
|
||||
--fg-color)
|
||||
FONTPREVIEW_FG_COLOR=$2
|
||||
;;
|
||||
--preview-text)
|
||||
FONTPREVIEW_PREVIEW_TEXT=$2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
# Point a font file to fontpreview and it will preview it.
|
||||
# Example:
|
||||
# $ fontpreview /path/to/fontFile.ttf
|
||||
#
|
||||
# This is useful because people can preview fonts which they have not
|
||||
# installed onto their system. So if they want to preview a font file that
|
||||
# is in their Downloads directory, then they can easily preview it.
|
||||
if [ -f "$font" ]; then
|
||||
generate_preview "$font" "$FONT_PREVIEW"
|
||||
|
||||
# Display the font preview using sxiv
|
||||
sxiv -g "$SIZE$POSITION" -N "fontpreview" -b "$FONT_PREVIEW" &
|
||||
|
||||
# For some strange reason, sxiv just doesnt have time to read the file
|
||||
sleep 0.1
|
||||
exit
|
||||
fi
|
||||
|
||||
# Check if the user gave an input file if they did, then create a preview
|
||||
# and then save the preview to the current working directory
|
||||
if [ "$input_file" != "" ] ; then
|
||||
[ -z "$output_file" ] && output_file="${input_file}.png"
|
||||
generate_preview "$input_file" "$output_file"
|
||||
exit
|
||||
fi
|
||||
|
||||
main
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Prints all batteries, their percentage remaining and an emoji corresponding
|
||||
# to charge status (🔌 for plugged up, 🔋 for discharging on battery, etc.).
|
||||
|
||||
# Loop through all attached batteries and format the info
|
||||
for battery in /sys/class/power_supply/BAT?*; do
|
||||
# If non-first battery, print a space separator.
|
||||
[ -n "${capacity+x}" ] && printf " "
|
||||
# Sets up the status and capacity
|
||||
case "$(cat "$battery/status" 2>&1)" in
|
||||
"Full") status="⚡" ;;
|
||||
"Discharging") status="🔋" ;;
|
||||
"Charging") status="🔌" ;;
|
||||
"Not charging") status="🛑" ;;
|
||||
"Unknown") status="♻️" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
capacity="$(cat "$battery/capacity" 2>&1)"
|
||||
# Will make a warn variable if discharging and low
|
||||
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗"
|
||||
# Prints the info
|
||||
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
|
||||
done && printf "\\n"
|
|
@ -1,16 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Status bar module for disk space
|
||||
# $1 should be drive mountpoint, otherwise assumed /.
|
||||
|
||||
location=${1:-/}
|
||||
|
||||
[ -d "$location" ] || exit
|
||||
|
||||
case "$location" in
|
||||
"/home"* ) icon="🏠" ;;
|
||||
"/mnt"* ) icon="💾" ;;
|
||||
*) icon="🖥";;
|
||||
esac
|
||||
|
||||
printf "%s: %s\n" "" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')"
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
free --mebi | sed -n '2{p;q}' | awk '{printf ("%2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Prints the current volume or 🔇 if muted.
|
||||
|
||||
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
|
||||
|
||||
# If muted, print 🔇 and exit.
|
||||
[ "$vol" != "${vol%\[MUTED\]}" ] && echo 🔇 && exit
|
||||
|
||||
vol="${vol#Volume: }"
|
||||
|
||||
split() {
|
||||
# For ommiting the . without calling and external program.
|
||||
IFS=$2
|
||||
set -- $1
|
||||
printf '%s' "$@"
|
||||
}
|
||||
|
||||
vol="$(printf "%.0f" "$(split "$vol" ".")")"
|
||||
|
||||
case 1 in
|
||||
$((vol >= 70)) ) icon="🔊" ;;
|
||||
$((vol >= 30)) ) icon="🔉" ;;
|
||||
$((vol >= 1)) ) icon="🔈" ;;
|
||||
* ) echo 🔇 && exit ;;
|
||||
esac
|
||||
|
||||
echo "$icon$vol%"
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Show wifi 📶 and percent strength or 📡 if none.
|
||||
# Show 🌐 if connected to ethernet or ❎ if none.
|
||||
# Show 🔒 if a vpn connection is active
|
||||
|
||||
# Wifi
|
||||
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
|
||||
wifiicon="$(awk '/^\s*w/ { print "📶", int($3 * 100 / 70) "% " }' /proc/net/wireless)"
|
||||
elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
|
||||
[ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📡 " || wifiicon="❌ "
|
||||
fi
|
||||
|
||||
# Ethernet
|
||||
[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon="❎"
|
||||
|
||||
# TUN
|
||||
[ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon=" 🔒"
|
||||
|
||||
printf "%s%s%s\n" "$wifiicon" "$ethericon" "$tunicon"
|
24
.local/bin/system/bar
Executable file
24
.local/bin/system/bar
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
bat=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||
disk=$(df -h / | awk 'NR==2 {gsub("G", "", $3); gsub("G", "", $2); print $3 "/" $2}')
|
||||
mem=$(free --mebi | sed -n '2{p;q}' | awk '{printf ("%2.2fGiB\n", ( $3 / 1024))}')
|
||||
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
|
||||
if echo "$vol" | grep -q "\[MUTED\]"; then
|
||||
vol="X"
|
||||
else
|
||||
vol="$(($(echo "$vol" | awk '{print $2}' | tr -d '.')))%%"
|
||||
fi
|
||||
|
||||
# Wifi
|
||||
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
|
||||
wifiicon="$(awk '/^\s*w/ { print int($3 * 100 / 70) "%%" }' /proc/net/wireless)"
|
||||
elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
|
||||
[ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon="📡 " || wifiicon="❌ "
|
||||
fi
|
||||
|
||||
# Ethernet
|
||||
[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon="🌐" || ethericon=""
|
||||
|
||||
net=$(echo "$wifiicon""$ethericon")
|
||||
notify-send "$(printf "NET: $net | VOL: $vol | BAT: $bat%% | SSD: $disk | RAM: $mem | $(date '+%b %d %H:%M:%S')\n")"
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
n2="50:DE:06:D7:C7:30"
|
||||
sink="bluez_output.50_DE_06_D7_C7_30.1"
|
||||
bluetoothctl power on
|
||||
bluetoothctl connect $n2
|
||||
pactl set-default-sink $sink
|
|
@ -1,8 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Use brillo to logarithmically adjust laptop screen brightness
|
||||
# and send a notification displaying the current brightness level after.
|
||||
|
||||
send_notification() {
|
||||
brightness=$(printf "%.0f\n" "$(brightnessctl i | grep 'Current brightness' | awk -F'[(%]' '{print $2}')")
|
||||
notify-send -a "brightness" -u low -r 9991 -h int:value:"$brightness" -h string:x-canonical-private-synchronous:sys-notify "Brightness: $brightness%" -t 2000
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
dwlb &
|
||||
someblocks -p | dwlb -status-stdin all &
|
||||
mako &
|
||||
wbg ~/.nky/Photo/Wallpapers/dark-cat-rosewater.jpg &
|
||||
gsettings set org.gnome.desktop.interface icon-theme "Catppuccin-SE"
|
||||
|
|
8
.local/bin/system/wmenu_run
Executable file
8
.local/bin/system/wmenu_run
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
IFS=:
|
||||
for p in $PATH; do
|
||||
for e in $p/*; do
|
||||
[ -x $e ] && echo ${e##*/}
|
||||
done
|
||||
done | sort -u | wmenu "$@" | ${SHELL:-"/bin/sh"} &
|
Loading…
Reference in a new issue