commit 26cda3289f56f71e354ce48d7e14ffca00cfcc70
parent c5e00f7452067c5d6e6e39a05f7520c76600b8de
Author: Mahdi Mirzade <[email protected]>
Date: Sun, 9 Oct 2022 01:40:29 +0330
Cleanup useless scripts, update scripts, add vis theme
Diffstat:
25 files changed, 238 insertions(+), 225 deletions(-)
diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf
@@ -64,6 +64,9 @@ ctrl+shift+s run "/bin/sh" "-c" "echo \"${sub-text}\" | tr ' ' '\n' | dmenu -i -
Ctrl+p run "/bin/sh" "-c" "xclip -selection c -o"
ctrl+p loadfile "$(xclip -selection c -o)" append-play
+
+c run "st" "-g" "81x25-10-10" "-e" "/bin/sh" "-c" "youtube-viewer --colorful --comments-order=relevance --comments='https://www.youtube.com/${filename}' --page=1 --no-interactive | less -R"
+
# ------------------------------------------------------------------------
# Mouse controls
# - Define mouse scrolling to change volume
diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf
@@ -63,6 +63,9 @@ save-position-on-quit
[extension.mp3]
video=no
geometry=250x250
+[extension.m4a]
+video=no
+geometry=250x250
# If webm file is selected, playback forever.
[extension.webm]
diff --git a/.config/okshrc b/.config/okshrc
@@ -8,9 +8,14 @@ done; unset command
alias startx="startx \"$XINITRC\""
alias \
- ..='cd ..' \
- ...='cd ../..' \
- ....='cd ../../..'
+ ls="ls -hN --color=auto --group-directories-first" \
+ ip="ip --color=auto" \
+ grep="grep --color=auto" \
+ diff="diff --color=auto"
+alias \
+ ..="cd .." \
+ ...="cd ../.." \
+ ....="cd ../../.."
alias \
c="clear -x" \
d="doas" \
@@ -48,4 +53,6 @@ else
fi
fi
+PS1=' \\w $ '
+#PS1=' \\u@\\h \\w $ '
export PS1
diff --git a/.config/vis/themes/my-theme.lua b/.config/vis/themes/my-theme.lua
@@ -0,0 +1,35 @@
+local lexers = vis.lexers
+lexers.STYLE_DEFAULT ='back:default,fore:white'
+lexers.STYLE_NOTHING = 'back:black'
+lexers.STYLE_CLASS = 'fore:yellow,bold'
+lexers.STYLE_COMMENT = 'fore:blue,bold'
+lexers.STYLE_CONSTANT = 'fore:cyan,bold'
+lexers.STYLE_DEFINITION = 'fore:blue,bold'
+lexers.STYLE_ERROR = 'fore:red,italics'
+lexers.STYLE_FUNCTION = 'fore:blue,bold'
+lexers.STYLE_KEYWORD = 'fore:yellow,bold'
+lexers.STYLE_LABEL = 'fore:green,bold'
+lexers.STYLE_NUMBER = 'fore:red,bold'
+lexers.STYLE_OPERATOR = 'fore:cyan,bold'
+lexers.STYLE_REGEX = 'fore:green,bold'
+lexers.STYLE_STRING = 'fore:red,bold'
+lexers.STYLE_PREPROCESSOR = 'fore:magenta,bold'
+lexers.STYLE_TAG = 'fore:red,bold'
+lexers.STYLE_TYPE = 'fore:green,bold'
+lexers.STYLE_VARIABLE = 'fore:blue,bold'
+lexers.STYLE_WHITESPACE = ''
+lexers.STYLE_EMBEDDED = 'back:blue,bold'
+lexers.STYLE_IDENTIFIER = 'fore:white'
+
+lexers.STYLE_LINENUMBER = 'fore:white'
+lexers.STYLE_LINENUMBER_CURSOR = lexers.STYLE_LINENUMBER
+lexers.STYLE_CURSOR = 'reverse'
+lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:yellow'
+lexers.STYLE_CURSOR_LINE = 'underlined'
+lexers.STYLE_COLOR_COLUMN = 'back:red'
+lexers.STYLE_SELECTION = 'back:white'
+lexers.STYLE_STATUS = 'reverse'
+lexers.STYLE_STATUS_FOCUSED = 'reverse,bold'
+lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
+lexers.STYLE_INFO = 'fore:default,back:default,bold'
+lexers.STYLE_EOF = ''
diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua
@@ -17,32 +17,6 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win)
vis:command('set autoindent on')
end)
--- Backspace removes 4 spaces if need be
-vis:map(vis.modes.INSERT, '<Backspace>', function()
- local tabwidth = 4
- local single_selection = false
- for selection in vis.win:selections_iterator() do
- if single_selection then
- single_selection = false
- break
- end
- single_selection = true
- end
-
- local to_stop = (vis.win.selection.col - 1) % tabwidth
- if to_stop == 0 then
- to_stop = tabwidth
- end
-
- if single_selection and to_stop > 1 and
- vis.win.file:content(vis.win.selection.pos - to_stop, to_stop) ==
- string.rep(' ', to_stop) then
- vis:feedkeys(string.rep('<vis-delete-char-prev>', to_stop))
- else
- vis:feedkeys('<vis-delete-char-prev>')
- end
-end, "Backspace removes 4 spaces if need be")
-
-- Strip trailing spaces
vis:command_register("sts", function(argv, force, win, selection, range)
local lines = win.file.lines
diff --git a/.config/x11/xinitrc b/.config/x11/xinitrc
@@ -1,17 +1,22 @@
#!/bin/sh
-UXR="${XDG_CONFIG_HOME:-$HOME/.config}"/x11/xresources
-UMM="${XDG_CONFIG_HOME:-$HOME/.config}"/x11/xmodmap
+# Disable [Energy Star/Screensaver] features
+xset -dpms
+xset s off
+
+# Reload Xresources/Xmodmap
+UXR=${XDG_CONFIG_HOME:-$HOME/.config}/x11/xresources
+UMM=${XDG_CONFIG_HOME:-$HOME/.config}/x11/xmodmap
[ -f "$UXR" ] && xrdb -merge "$UXR"
[ -f "$UMM" ] && xmodmap "$UMM"
# Autostart:
-pidof "theme-sel" || theme-sel -x
-pidof "bg-gen" || bg-gen &
-pidof "dwm-bar" || dwm-bar &
-pidof "pipewire" || pipewire &
-xset -dpms # Disables Energy Star features
-xset s off # Disables screen saver
+theme-sel -x
+bg-gen &
+dwm-bar &
+pipewire &
+pipewire-pulse &
+pipewire-media-session &
# Monitors:
i=0
@@ -37,4 +42,5 @@ xmodmap -e "keycode 108 = p P Arabic_hah bracketleft"
xmodmap -e "add mod1 = Alt_L Meta_L"
# Add -f after startx to experience dwm in floating mode.
-ssh-agent dwm "$@"
+exec dbus-launch dwm "$@"
+#ssh-agent dwm "$@"
diff --git a/.local/bin/bg-gen b/.local/bin/bg-gen
@@ -2,7 +2,7 @@
bg_set() { xwallpaper --zoom "$1"; }
CL1=$(xrdb -query | awk '/color0/{print $2;exit}')
-CL2=$(xrdb -query | awk '/color12/{print $2;exit}')
+CL2=$(xrdb -query | awk '/color7/{print $2;exit}')
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/bg-gen"
IMG="${XDG_CACHE_HOME:-$HOME/.cache}/bg-gen/${CL1}_${CL2}.png"
@@ -13,7 +13,7 @@ if [ ! -f "$IMG" ]; then
#TAGS="xc: -attenuate 0.3 +noise Random"
#TAGS="xc: -attenuate 0.3 +noise Random -paint 10"
TAGS="plasma:"
- magick -size "$RES" $TAGS \
+ convert -size "$RES" $TAGS \
-channel B -separate +channel \
+level-colors "$CL1,$CL2" \
"$IMG"
diff --git a/.local/bin/dmenu-emoji b/.local/bin/dmenu-emoji
@@ -4,10 +4,13 @@ emoji=$(sed '/^__DATA__$/,$!d;/^__DATA__$/d;s/\ufe0f//g' "$(which "$0")" | dmenu
[ "$emoji" ] || exit
xdotool windowactivate "$active_window"
+NOTIF_MSG="ﲃ Emoji
+Copied $emoji to clipboard!"
+
case "$1" in
[Cc]|[Cc][Ll][Ii][Pp][Bb][Oo][Aa][Rr][Dd])
echo "$emoji" | xclip -selection clipboard
- notify "Emoji" "Copied $emoji to clipboard!"
+ notify "$NOTIF_MSG"
;;
*)
xdotool type -delay 100 "$emoji"
diff --git a/.local/bin/dmenu-fix-sheet b/.local/bin/dmenu-fix-sheet
@@ -1,9 +1,9 @@
#!/bin/sh
# Some cheatsheet for some fast fixes wouldn't be bad.
-CHOICE="$(printf '%s\n' "background noise in pulse" \
- | dmenu -p "Get Help For Some Quick Fix:" -l 20)"
+CHOICE="$(printf '%s\n' "background noise in pulse" \
+ | dmenu -p "Get Help For Some Quick Fix:" -l 20)"
case "$CHOICE" in
- "background noise in pulse")
+ "background noise in pulse")
printf '# My fix for background noise in pulse.\n'
printf '#\n'
printf '# 1. Run privilaged:\n'
diff --git a/.local/bin/dmenu-mpd b/.local/bin/dmenu-mpd
@@ -9,10 +9,10 @@ prev_song="$(mpc playlist | sed -n ${prev_song}p)"
curr_song="$(mpc --format '[%title%|%file%]' current)"
n=0
-[ ! "$next_song" ] || btn_next="⏭️ Next Song (\"$next_song\")"
-[ ! "$prev_song" ] || btn_prev="⏮️ Prev Song (\"$prev_song\")"
-[ ! "$curr_song" ] || btn_play="⏯️ Play (\"$curr_song\")" \
- && btn_pause="⏸️ Pause (\"$curr_song\")" && mpc status | grep -q 'playing' \
+[ ! "$next_song" ] || btn_next="ﭠ Next Song (\"$next_song\")"
+[ ! "$prev_song" ] || btn_prev="ﭢ Prev Song (\"$prev_song\")"
+[ ! "$curr_song" ] || btn_play=" Play (\"$curr_song\")" \
+ && btn_pause=" Pause (\"$curr_song\")" && mpc status | grep -q 'playing' \
&& btn_curr="$btn_pause" || btn_curr="$btn_play"
([ "$btn_curr" ] || [ "$btn_next" ] || [ "$btn_prev" ]) && \
seperator="-----------------------------------------------------------------------------------"
diff --git a/.local/bin/dmenu-power b/.local/bin/dmenu-power
@@ -1,16 +1,16 @@
#!/bin/sh
ask() {
doas-askpass "$2"
- #prompt="Do you really want to $1?"
- #answer="$(printf 'Yes\nNo' | dmenu -i -p "$prompt")"
- #[ "$answer" = "Yes" ] && doas-askpass "$2"
+ #prompt="Do you really want to $1?"
+ #answer="$(printf 'Yes\nNo' | dmenu -i -p "$prompt")"
+ #[ "$answer" = "Yes" ] && doas-askpass "$2"
}
-btn_power="📴 Poweroff"
-btn_reboot="🔄 Reboot"
-btn_logout="🚪 Logout"
+btn_power="⏻ Poweroff"
+btn_reboot=" Reboot"
+btn_logout=" Logout"
-CHOICE="$(printf '%s\n' "$btn_logout" "$btn_reboot" "$btn_power" | dmenu -i -p "🔌 Powermenu:")"
+CHOICE="$(printf '%s\n' "$btn_logout" "$btn_reboot" "$btn_power" | dmenu -i -p "ﮣ Powermenu:")"
[ "$CHOICE" ] || exit 2
case "$CHOICE" in
diff --git a/.local/bin/dwm-bar b/.local/bin/dwm-bar
@@ -59,7 +59,7 @@ Weather(){
weather_file_last=$(stat -c%Y "$weather_file")
if [ "$(date +%s)" -ge $((weather_file_last+3600)) ]; then
for interface in $(find /sys/class/net -depth | \
- sed '/\/lo$/d;/\/net$/d'); do
+ sed '/\/lo$/d;/\/net$/d'); do
if [ "$(cat "$interface" 2>/dev/null)" -eq 1 ]; then
rm "$weather_file"
break
@@ -69,14 +69,14 @@ Weather(){
weather=$(cat "$weather_file" 2>/dev/null)
if [ ! "$weather" ]; then
- weather=$(curl -s "v2d.wttr.in/${WEATHER_LOC}" | \
+ weather=$(curl -s "v2d.wttr.in/$WEATHER_LOC" | \
sed "/Weather:/!d;s/Weather://;s/,//g;
s/+//g;s/°C.*//;s/.*m//;s/ //;s/ //;s/ //")
weather="${weather}°C"
echo "$weather" > "$weather_file"
fi
- [ "$weather" ] && printf "%s" "${weather}"
+ [ "$weather" ] && printf "%s" "$weather"
}
PublicIP(){
@@ -124,7 +124,7 @@ PrivateIP(){
Keyboard(){
KBD_LAYOUTS=$(setxkbmap -query | awk '/layout/{print $2}' | \
tr ',' '\n' | awk '{print NR-1":"$1}')
- KBD=$(xset -q | grep LED | awk '{ print substr($10,5,1) }')
+ KBD=$(xset -q | grep LED | awk '{print substr($10,5,1)}')
KBD=$(echo "$KBD_LAYOUTS" | sed "/^$KBD:/!d;s/.*://")
[ "$KBD" ] && printf " %s" "$KBD"
}
@@ -147,8 +147,8 @@ Battery() {
Linux*)
BAT=$(find /sys/class/power_supply/ -name "BAT*")
if [ -d "$BAT" ]; then
- CAPACITY=$(cat "${BAT}/capacity")
- CHARGING=$(cat "${BAT}/status")
+ CAPACITY=$(cat "$BAT/capacity")
+ CHARGING=$(cat "$BAT/status")
fi
[ "$CHARGING" = "Charging" ] && ICON=$CHARGING_ICON
;;
@@ -201,8 +201,8 @@ Brightness() {
case "$KERNEL" in
*Linux*)
BRIGHTNESS_CARD=$(find /sys/class/backlight -depth | head -n 1)
- BRIGHTNESS_MAX=$(cat "${BRIGHTNESS_CARD}/max_brightness")
- BRIGHTNESS=$(cat "${BRIGHTNESS_CARD}/brightness")
+ BRIGHTNESS_MAX=$(cat "$BRIGHTNESS_CARD/max_brightness")
+ BRIGHTNESS=$(cat "$BRIGHTNESS_CARD/brightness")
BRIGHTNESS=$((BRIGHTNESS*100/BRIGHTNESS_MAX))
BRIGHTNESS=${BRIGHTNESS%.*}
;;
@@ -226,8 +226,9 @@ Brightness() {
Volume() {
case "$KERNEL" in
Linux*)
- if pactl stat 2>/dev/null; then
- VOLUME=$(pactl get-sink-volume @DEFAULT_SOURCE@ | \
+ if pactl stat >/dev/null 2>&1; then
+ DEFAULT_SINK=$(pactl get-default-sink)
+ VOLUME=$(pactl get-sink-volume "$DEFAULT_SINK" | \
awk '/%/{sub(/%/, "", $5);print $5}')
else
VOLUME=$(amixer sget Master on | \
@@ -384,11 +385,11 @@ startbar() {
#mod_output=$($mod)
mod_output=$(cat "$CACHE_DIR/mod-$mod")
if [ -z "$mod_output" ]; then
- out=$(printf "%s" "${out}" | \
- sed "s/$mod_sep$mod_prefix%$mod%$mod_suffix//")
+ out=$(printf "%s" "$out" | \
+ sed "s|$mod_sep$mod_prefix%$mod%$mod_suffix||")
continue
fi
- out=$(printf "%s" "${out}" | sed "s/%$mod%/$mod_output/g")
+ out=$(echo "$out" | sed "s|%$mod%|$mod_output|")
done
dwm -s "$out"
sleep 1
@@ -407,14 +408,15 @@ updatebar() {
main() {
while getopts "m:M" flag; do
- case "${flag}" in
+ case "$flag" in
M)
full_text="[All Modules]"
rest="[Restart Modules]"
cust="[Custom Modules]"
- opts=$(printf "%s" "${opts_mods}" | sed 's/^[ \t]*//g;/^ *$/d')
+ opts=$(echo "$opts_mods" | \
+ sed 's/^[ \t]*//g;/^ *$/d' | column -t)
choice=$(printf "%s\n" \
- "${full_text}" "${rest}" "${cust}" "${opts}" | dmenu -i -l 20)
+ "$full_text" "$rest" "$cust" "$opts" | dmenu -i -l 20)
[ -z "$choice" ] && choice=$(cat "$CACHE_DIR/Modules")
case "$choice" in
"$cust")
@@ -442,7 +444,7 @@ main() {
echo "$mods" > "$CACHE_DIR/Modules"
;;
m)
- mods=${OPTARG}
+ mods=$OPTARG
echo "$mods" > "$CACHE_DIR/Modules"
;;
*) usage ;;
diff --git a/.local/bin/email b/.local/bin/email
@@ -4,6 +4,9 @@ SYNC_MAIL=0
SYNC_MAIL_FREQ=0
SYNC_MAIL_FREQ_SECS=1800
+NOTIFY_MSG=" New Mail
+You have %N% new mail%S% in '%A%'."
+
MBSYNCRC="${MBSYNCRC:-${XDG_CONFIG_HOME:-$HOME/.config}/mbsync/mbsyncrc}"
MBSYNC_ACCS="${XDG_DATA_HOME:-$HOME/.local/share}/mail"
sync_mail() {
@@ -17,9 +20,10 @@ sync_mail() {
-type f -newer "$LAST_RUN" 2>/dev/null | wc -l | sed 's/ //g')
if [ "$NEW_MAILS" -ge 1 ]; then
[ "$NEW_MAILS" -gt 1 ] && SUF="s" || SUF=""
- ACC_SHOW="${ACC##*/}"
- notify " New Mail
-You have ${NEW_MAILS} new mail${SUF} in '${ACC_SHOW}'."
+ ACC_SHOW=${ACC##*/}
+ MSG=$(echo "$NOTIFY_MSG" |
+ sed "s|%N%|$NEW_MAILS|;s|%S%|$SUF|;s|%A%|$ACC_SHOW|")
+ notify "$MSG"
fi
touch "$LAST_RUN"
done
diff --git a/.local/bin/notify b/.local/bin/notify
@@ -1,14 +1,27 @@
#!/bin/sh
+WAIT=5
TEXT=$*
[ "$TEXT" ] || TEXT=$(cat -u -)
+TEXT=$(echo "$TEXT" | fold -s -w 80)
+
FONT="JetBrainsMono Nerd Font:pixelsize=12:antialias=true:autohint=true"
-WIDTH=$(($(printf '%s' "$TEXT" | \
- awk 'length>max{max=length}END{print max}')*6+40))
-HEIGHT=40
-LINES=$(($(echo "$TEXT" | wc -l)-1))
+WIDTH=$(printf '%s' "$TEXT" | \
+ awk 'length>max{max=length}END{print max}')
+WIDTH=$((WIDTH*10))
+LINES_COUNT=$(echo "$TEXT" | wc -l)
+LINES_COUNT=$((LINES_COUNT-1))
+HEIGHT=$((LINES_COUNT*5))
+
+[ $WIDTH -gt 600 ] && WIDTH=600
+[ $LINES_COUNT -eq 0 ] && HEIGHT=5
+
PADDING=40
-WAIT=5
+
+[ $LINES_COUNT -gt 2 ] && PADDING=20
+
+WIDTH=$((WIDTH+PADDING))
+HEIGHT=$((HEIGHT+PADDING))
WIDTHxHEIGHT=$(xrandr | sed '/*/!d' |awk '{print $1;exit}')
M_WIDTH=${WIDTHxHEIGHT%%x*}
@@ -53,9 +66,9 @@ darken_hex(){
}
BG_COLOR=$(xrdb -query | awk '/background/{print $2;exit}')
-BG_COLOR=$(darken_hex "$BG_COLOR" "-5")
+BG_COLOR=$(darken_hex "$BG_COLOR" "-10")
-FG_COLOR=$(xrdb -query | awk '/color12/{print $2;exit}')
+FG_COLOR=$(xrdb -query | awk '/foreground/{print $2;exit}')
pkill dzen2
(
@@ -65,7 +78,7 @@ printf '%s\n' "$TEXT" | while IFS= read -r NOTIF; do
done
sleep $WAIT
) | dzen2 \
- -l $LINES \
+ -l $LINES_COUNT \
-ta c \
-sa c \
-x $N_WIDTH \
diff --git a/.local/bin/pacman-rm b/.local/bin/pacman-rm
@@ -1,6 +0,0 @@
-#!/bin/sh
-alias fzf="fzf -i -m -e --layout=reverse --border=sharp --inline-info --cycle --preview=\"pacman --color=always -Si {3}\" --bind 'Ctrl-p:toggle-preview+toggle-preview' --bind='Ctrl-a:toggle-all'"
-packages="$(pacman -Qi | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -hr | tr ' ' '\t' | sed -e "s/MiB/ MiB/g" -e "s/KiB/ KiB/g")"
-pkgs="$(printf "%s" "$packages" | fzf | awk '{print $3}' | tr '\n' ' ')"
-
-[ "$pkgs" ] && doas pacman -Rcusn $pkgs
diff --git a/.local/bin/pacman-up b/.local/bin/pacman-up
@@ -1,34 +0,0 @@
-#!/bin/sh
-notif() {
- notify " Updater" "$1"
-}
-notifnq() {
- TEXT="${1}"
- [ "$TEXT" ] || TEXT="Didn't update anything."
- notif "$TEXT"
- exit 2
-}
-
-doas-askpass pacman -Sy || notifnq
-PKG_LIST="$(pacman -Su --print-format "%r/%n %s" | sort -r -n -k 2)"
-
-[ -z "$PKG_LIST" ] && notifnq "System is up-to-date." && rm ~/.cache/pkg_updates
-
-PKG_LIST_H="$(printf '%s\n' "$PKG_LIST" | awk '{printf("%s %.1fMiB\n",$1,$2/1024/1024)}')"
-PKG_COUNT="$(printf '%s\n' "$PKG_LIST" | wc -l)"
-PKG_SIZE="$(printf '%s\n' "$PKG_LIST" | awk '{SUM+=$2} END {printf("%.1fMiB",SUM/1024/1024)}')"
-
-[ "$PKG_COUNT" -gt 1 ] && SUFFIX="s"
-notify "$(printf "Packages:\n$PKG_LIST_H" | head)"
-CHOICE="$(printf '%s\n' "Yes" "No" | dmenu -p "Update $PKG_COUNT Package$SUFFIX ($PKG_SIZE)?")"
-case "$CHOICE" in
- [Yy][Ee][Ss]|[Yy])
- notif "Updating $PKG_COUNT Package$SUFFIX..."
- "$TERMINAL" -c "st-float" -g "120x26" -e sh -c "doas pacman -Syu --noconfirm || (notify \" Updater\" \"Didn't update anything.\" && exit 2)"
- rm ~/.cache/pkg_updates
- notifnq "Updated $PKG_COUNT Package$SUFFIX."
- ;;
- *)
- notifnq
- ;;
-esac
diff --git a/.local/bin/screenshot b/.local/bin/screenshot
@@ -6,7 +6,7 @@ QUALITY=5
COPY_SS=0
SAVE_SS=0
NAME_SS="$(date '+%Y%m%d-%H%M%S').png"
-SAVE_SS_DIR="$HOME/pics"
+SAVE_SS_DIR="$HOME/Pictures/Screenshots"
while getopts :wscxt:q:n:p: flag; do
case "${flag}" in
@@ -44,4 +44,7 @@ elif [ $SAVE_SS -eq 1 ] && [ $COPY_SS -eq 0 ]; then
SHOW="$(echo "${SAVE_SS_DIR}" | sed -e "s|${HOME}|~|g")/${NAME_SS}"
fi
-notify " Picture acquired!" "${SHOW}"
+NOTIF_MSG=" Picture acquired!
+$SHOW"
+
+notify "$NOTIF_MSG"
diff --git a/.local/bin/snd b/.local/bin/snd
@@ -34,17 +34,19 @@ vol() {
case "$(uname)" in
"Linux"*)
if pactl stat >/dev/null 2>&1; then
+ DEFAULT_SINK=$(pactl get-default-sink)
+ DEFAULT_SOURCE=$(pactl get-default-source)
case "$1" in
- get) pactl get-sink-volume @DEFAULT_SOURCE@ | awk '/%/{sub(/%/, "", $5);print $5}' ;;
- inc) pactl set-sink-volume @DEFAULT_SINK@ "+$2%" ;;
- dec) pactl set-sink-volume @DEFAULT_SINK@ "-$2%" ;;
- mute) pactl set-sink-mute @DEFAULT_SINK@ toggle ;;
- ismuted) pactl get-sink-mute @DEFAULT_SOURCE@ | grep -o 'yes' ;;
- mic-get) pactl get-source-volume @DEFAULT_SOURCE@ | awk '/%/{sub(/%/, "", $5);print $5}' ;;
- mic-inc) pactl set-source-volume @DEFAULT_SINK@ "+$2%" ;;
- mic-dec) pactl set-source-volume @DEFAULT_SINK@ "-$2%" ;;
- mic-mute) pactl set-source-mute @DEFAULT_SINK@ toggle ;;
- mic-ismuted) pactl get-source-mute @DEFAULT_SOURCE@ | grep -o 'yes' ;;
+ get) pactl get-sink-volume $DEFAULT_SINK | awk '/%/{sub(/%/, "", $5);print $5}' ;;
+ inc) pactl set-sink-volume $DEFAULT_SINK "+$2%" ;;
+ dec) pactl set-sink-volume $DEFAULT_SINK "-$2%" ;;
+ mute) pactl set-sink-mute $DEFAULT_SINK toggle ;;
+ ismuted) pactl get-sink-mute $DEFAULT_SINK | grep -o 'yes' ;;
+ mic-get) pactl get-source-volume $DEFAULT_SOURCE | awk '/%/{sub(/%/, "", $5);print $5}' ;;
+ mic-inc) pactl set-source-volume $DEFAULT_SINK "+$2%" ;;
+ mic-dec) pactl set-source-volume $DEFAULT_SINK "-$2%" ;;
+ mic-mute) pactl set-source-mute $DEFAULT_SINK toggle ;;
+ mic-ismuted) pactl get-source-mute $DEFAULT_SOURCE | grep -o 'yes' ;;
esac
else
case "$1" in
diff --git a/.local/bin/torrent-from-clip b/.local/bin/torrent-from-clip
@@ -1,4 +1,7 @@
#!/bin/sh
+NOTIFY_MSG=" Added Torrent
+%PASTE%"
+
while :; do
clip=$(xclip -selection c -o)
case "$clip" in
@@ -7,8 +10,8 @@ while :; do
if [ "$url" != "$clip" ]; then
qbittorrent-nox "$clip"
echo "$clip" > ~/.cache/url.txt
- notify "Added Torrent
-$clip"
+ MSG=$(echo "$NOTIFY_MSG" | sed "s|%PASTE%|$clip|")
+ notify "$MSG"
fi
;;
esac
diff --git a/.local/bin/vpn b/.local/bin/vpn
@@ -1,50 +0,0 @@
-#!/bin/sh
-prepare() {
- (echo "nameserver 1.1.1.1";
- echo "nameserver 1.0.0.1";
- echo "nameserver 208.67.222.222";
- echo "nameserver 208.67.220.220") > /etc/resolv.conf
-
- cd /dev || exit
- mkdir net
- mknod net/tun c 10 200
- chmod 0666 net/tun
-}
-
-stopvpn() {
- for pid in $(ps ax | grep openvpn | awk '{print $1}'); do
- [ "$pid" = "$$" ] && continue
- kill -9 "$pid" > /dev/null 2>&1
- wait
- done
-}
-
-startvpn() {
- printf "\033[90m"
- openvpn /home/mahdi/.local/share/Mahdi.ovpn
- printf "\033[0m"
-}
-
-loopvpn() {
- while :; do
- stopvpn
- startvpn
- done
-}
-
-prepare
-clear
-
-case "$1" in
- start)
- startvpn
- ;;
- stop)
- stopvpn
- ;;
- *)
- loopvpn &
- trap loop INT
- trap loop EXIT
- ;;
-esac
diff --git a/.local/bin/webcam b/.local/bin/webcam
@@ -2,8 +2,15 @@
WEBCAM_DRIVER=v4l2
WEBCAM_DEVICE=$(find /dev -name "video*" | sort | sed -n '1p')
-if [ ! -e "${WEBCAM_DEVICE}" ]; then
- notify "Webcam" "Install a webcam first!"
+NOTIFY_NA=" Webcam
+Install a webcam first!"
+NOTIFY_OPEN_MSG=" Webcam
+$WEBCAM_DEVICE is open now."
+NOTIFY_CLOSE_MSG=" Webcm
+$WEBCAM_DEVICE has been closed."
+
+if [ ! -e "$WEBCAM_DEVICE" ]; then
+ notify "$NOTIFY_NA"
exit 2
fi
@@ -15,9 +22,9 @@ case "$1" in
*)
ps ax | grep "mpv*av://$WEBCAM_DRIVER:$WEBCAM_DEVICE*" | \
awk '{print $1}' | while read -r PID; do kill -9 "$PID"; wait; done
- notify " Webcam" "$WEBCAM_DEVICE is open now."
+ notify "$NOTIFY_OPEN_MSG"
mpv "av://$WEBCAM_DRIVER:$WEBCAM_DEVICE" --title=webcam \
--profile=low-latency --untimed --load-scripts=no --no-osc
- notify " Webcam" "$WEBCAM_DEVICE has been closed."
+ notify "$NOTIFY_CLOSE_MSG"
;;
esac
diff --git a/Makefile b/Makefile
@@ -7,23 +7,21 @@ help:
@grep '^[a-zA-Z_-]*:.*## .*$$' Makefile \
| awk -F ':.*##' '{printf "\033[34m%-20s\033[0m %s\n", $$1, $$2}'
+font: ## Install fonts to $HOME/.local/share/fonts
+ git submodule update --init --remote ${PWD}/.local/share/fonts
+ mkdir -p ${HOME}/.local/share/fonts
+ $(CP) ${PWD}/.local/share/fonts/* ${HOME}/.local/share/fonts
+ fc-cache -f
+
link: ## Force link dotfiles to $HOME
@for CONFIG_MKDIR in $(CONFIGS_MKDIR); do $(MKDIR) $${HOME}/$$CONFIG_MKDIR; done
@for CONFIG_FILE in $(CONFIGS_FILES); do $(LN) $${PWD}/$$CONFIG_FILE $${HOME}/$$CONFIG_FILE; done
- $(EXTRACT) ${HOME}/.local/share/fonts.tar.gz
- $(RUN_PERM) mkdir -p /usr/share/fonts/TTF/
- $(RUN_PERM) install -Dm 755 ${HOME}/.local/share/fonts/* /usr/share/fonts/TTF/
- $(RUN_PERM) fc-cache -f
$(RUN_PERM) $(MKDIR) /etc/X11/xorg.conf.d
$(RUN_PERM) $(LN) etc/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/40-libinput.conf
copy: ## Force copy dotfiles to $HOME
@for CONFIG_DIR in $(CONFIGS_MKDIR); do $(MKDIR) $${HOME}/$$CONFIG_DIR; done
@for CONFIG_FILE in $(CONFIGS_FILES); do $(CP) $${PWD}/$$CONFIG_FILE $${HOME}/$$CONFIG_FILE; done
- $(EXTRACT) ${HOME}/.local/share/fonts.tar.gz
- $(RUN_PERM) mkdir -p /usr/share/fonts/TTF/
- $(RUN_PERM) install -Dm 755 ${HOME}/.local/share/fonts/* /usr/share/fonts/TTF/
- $(RUN_PERM) fc-cache -f
$(RUN_PERM) $(MKDIR) /etc/X11/xorg.conf.d
$(RUN_PERM) $(CP) etc/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/40-libinput.conf
@@ -79,63 +77,63 @@ backup-files: ## Force copy files from ~/ to ./ (inc/configs-files.mk)
dmenu: ## Install my build of dmenu
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/dmenu
- cd ${PWD}/.local/src/dmenu; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/dmenu
cp -rf ${PWD}/.local/src/dmenu ${HOME}/.local/src/dmenu
cd ${HOME}/.local/src/dmenu; $(RUN_PERM) make install
dzen2: ## Install dzen2
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/dzen2
- cd ${PWD}/.local/src/dzen2; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/dzen2
cp -rf ${PWD}/.local/src/dzen2 ${HOME}/.local/src/dzen2
cd ${HOME}/.local/src/dzen2; $(RUN_PERM) make install
dwm: ## Install my build of dwm
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/dwm
- cd ${PWD}/.local/src/dwm; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/dwm
cp -rf ${PWD}/.local/src/dwm ${HOME}/.local/src/dwm
cd ${HOME}/.local/src/dwm; $(RUN_PERM) make install
slock: ## Install my build of slock
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/slock
- cd ${PWD}/.local/src/slock; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/slock
cp -rf ${PWD}/.local/src/slock ${HOME}/.local/src/slock
cd ${HOME}/.local/src/slock; $(RUN_PERM) make install
smenu: ## Install smenu
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/smenu
- cd ${PWD}/.local/src/smenu; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/smenu
cp -rf ${PWD}/.local/src/smenu ${HOME}/.local/src/smenu
cd ${HOME}/.local/src/slock; ./configure; ./build.sh; $(RUN_PERM) make install
st: ## Install my build of st
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/st
- cd ${PWD}/.local/src/st; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/st
cp -rf ${PWD}/.local/src/st ${HOME}/.local/src/st
cd ${HOME}/.local/src/st; $(RUN_PERM) make install
surf: ## Install my build of surf
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/surf
- cd ${PWD}/.local/src/surf; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/surf
cp -rf ${PWD}/.local/src/surf ${HOME}/.local/src/surf
cd ${HOME}/.local/src/surf; $(RUN_PERM) make install
tabbed: ## Install my build of tabbed
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/tabbed
- cd ${PWD}/.local/src/tabbed; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/tabbed
cp -rf ${PWD}/.local/src/tabbed ${HOME}/.local/src/tabbed
cd ${HOME}/.local/src/tabbed; $(RUN_PERM) make install
xwallpaper: ## Install my build of xwallpaper
$(MKDIR) ${HOME}/.local/src
rm -rf ${HOME}/.local/src/xwallpaper
- cd ${PWD}/.local/src/xwallpaper; git submodule init; git submodule update
+ git submodule update --init --remote ${PWD}/.local/src/xwallpaper
cp -rf ${PWD}/.local/src/xwallpaper ${HOME}/.local/src/xwallpaper
cd ${HOME}/.local/src/xwallpaper; ./autogen.sh; $(RUN_PERM) make install
diff --git a/README b/README
@@ -1,30 +1,29 @@
dotfiles
--------
-These are my dotfiles for my desktop (running aside my suckless forks)
~/.config
-├── dunst: Notification daemon
├── fontconfig: Font configuration
├── git: Content tracker
├── Kvantum: Theme engine for QT
├── mbsync: Synchronize mailboxes (isync)
├── mpv: Audio/Video player
├── mutt: Email client
-├── qutebrowser: Web browser [Backup surf]
+├── qutebrowser: Web browser [Backup to surf]
├── shell: Shell configuration/Env files
├── surf: Web browser
├── vis: Text editor
├── wget: Network downloader [Backup for curl -O]
├── x11: Graphical server
├── yt-dlp: Download videos from many platforms
-└── zathura: Document viewer
+├── zathura: Document viewer
+└── okshrc: OpenBSD's Korn Shell config
~/.local
├── bin
-│ ├── backlight: Manage monitor brightness for my laptop
│ ├── bg-gen: Generate abstract wallpaper from my Xresources
│ ├── bg-set: Set wallpaper from ~/.local/share/wallpapers
using fzf and image previes (old)
+│ ├── bright: Manage monitor brightness for my laptop
│ ├── dmenu-archwiki: Navigate archwiki offline
│ ├── dmenu-askpass: Ask password for scripts (used for sudo/doas)
│ ├── dmenu-emoji: Emoji selector
@@ -40,22 +39,64 @@ These are my dotfiles for my desktop (running aside my suckless forks)
│ ├── lock: Close notifications and etc; Then lock screen (slock)
│ ├── media-controller: Manage multimedia in your desktop (fix this)
│ ├── metch: Mahdi's fetch
-│ ├── pacman-rm: Remove pacman packages sorted by size (old)
-│ ├── pacman-up: Update pacman packages using dmenu to view them (old)
+│ ├── pash: A simple password manager using GPG written in POSIX sh.
│ ├── screenshot: Screenshot like a boss using maim
+│ ├── snd: Manage volume (pulse)
│ ├── theme-sel: Select themes and reload your entire desktop's theme
(themes are stored in ~/.config/x11/themes)
│ ├── toggle-touch: Toggle touchpad for my laptop
+│ ├── torrent-from-clip: Until the script is killed, it'll read my clipboard and add magnet link to my torrent downloader
│ ├── upload: Upload files/directories into transfer.sh
-│ ├── volume: Manage volume (pulse)
│ └── webcam: Webcam using mpv
-└── share
- ├── fonts.tar.gz: My system fonts packaged
- └── icons.tar.gz: My system gtk icons packaged
+├── run
+├── share
+│ └── fonts: My system fonts
+├── src
+│ ├── dmenu: My build of dmenu
+│ ├── dwm: My build of dwm
+│ ├── dzen2: Dzen2 as notification
+│ ├── slock: My build of slock
+│ ├── smenu: smenu instead of fzf
+│ ├── st: My build of st
+│ ├── surf: My build of surf
+│ ├── tabbed: My build of tabbed
+│ └── xwallpaper: Wallpaper setter
+└── state
-~/.kshrc: Korn Shell
+─── .profile: Environment Variables
-~/.mkshrc: MirBsd's Korn Shell
+Clone this repo
+---------------
+You can clone the configurations/scripts:
+
+ git clone git://mahdi.pw/dotfiles.git
+
+Even with this method, once you want to install one of my sets, it'll clone it
+from source and then build it, as long as you have active internet connection,
+you won't worry about it.
+
+Also you can clone the full repository with its submodules:
+(includes all of my fonts colletion and builds)
+
+ git clone git://mahdi.pw/dotfiles.git
+ cd dotfiles
+ git submodule init
+ git submodule update
+
+ # or in one line:
+
+ git clone --recurse-submodules git://mahdi.pw/dotfiles.git
+
+But this is also too much and I don't need all the fonts when I'm in a hurry,
+so I'll either remove the 'fonts' submodule manually from .gitmodules, or:
+
+ git clone git://mahdi.pw/dotfiles.git
+ cd dotfiles
+ git -c submodule.".local/share/fonts".update=none \
+ submodule update --init --recursive
+
+This will clone this repository with submodules except the fonts submodule,
+which is ~27 MiB and it'll save resources.
Usage
-----
diff --git a/inc/configs-dirs.mk b/inc/configs-dirs.mk
@@ -10,6 +10,7 @@ CONFIGS_MKDIR += .config/qutebrowser
CONFIGS_MKDIR += .config/surf
CONFIGS_MKDIR += .config/surf/styles
CONFIGS_MKDIR += .config/vis
+CONFIGS_MKDIR += .config/vis/themes
CONFIGS_MKDIR += .config/wget
CONFIGS_MKDIR += .config/x11
CONFIGS_MKDIR += .config/x11/themes
@@ -19,5 +20,6 @@ CONFIGS_MKDIR += .local
CONFIGS_MKDIR += .local/bin
CONFIGS_MKDIR += .local/run
CONFIGS_MKDIR += .local/share
+CONFIGS_MKDIR += .local/share/fonts
CONFIGS_MKDIR += .local/src
CONFIGS_MKDIR += .local/state
diff --git a/inc/configs-files.mk b/inc/configs-files.mk
@@ -17,6 +17,7 @@ CONFIGS_FILES += .config/qutebrowser/config.py
CONFIGS_FILES += .config/surf/script.js
CONFIGS_FILES += .config/surf/styles/default.css
CONFIGS_FILES += .config/surf/styles/default.css.in
+CONFIGS_FILES += .config/vis/themes/my-theme.lua
CONFIGS_FILES += .config/vis/visrc.lua
CONFIGS_FILES += .config/wget/wgetrc
CONFIGS_FILES += .config/x11/colors
@@ -52,8 +53,6 @@ CONFIGS_FILES += .local/bin/lock
CONFIGS_FILES += .local/bin/media-controller
CONFIGS_FILES += .local/bin/metch
CONFIGS_FILES += .local/bin/notify
-CONFIGS_FILES += .local/bin/pacman-rm
-CONFIGS_FILES += .local/bin/pacman-up
CONFIGS_FILES += .local/bin/pash
CONFIGS_FILES += .local/bin/screenshot
CONFIGS_FILES += .local/bin/snd
@@ -61,9 +60,7 @@ CONFIGS_FILES += .local/bin/theme-sel
CONFIGS_FILES += .local/bin/toggle-touch
CONFIGS_FILES += .local/bin/torrent-from-clip
CONFIGS_FILES += .local/bin/upload
-CONFIGS_FILES += .local/bin/vpn
CONFIGS_FILES += .local/bin/webcam
CONFIGS_FILES += .local/run/.gitkeep
-CONFIGS_FILES += .local/share/fonts.tar.gz
CONFIGS_FILES += .local/state/.gitkeep
CONFIGS_FILES += .profile