summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS8
-rw-r--r--README.md6
-rw-r--r--TODO9
-rw-r--r--build.sh8
-rw-r--r--config/lf/lfrc6
-rw-r--r--config/shell/profile2
-rwxr-xr-xdaemons/dcheck_battery2
-rwxr-xr-xinstall2
-rwxr-xr-xscripts/gui/nsend28
-rwxr-xr-xscripts/gui/sclip21
-rwxr-xr-xscripts/gui/sslock49
-rwxr-xr-xscripts/gui/swall3
-rwxr-xr-xscripts/slib49
13 files changed, 138 insertions, 55 deletions
diff --git a/BUGS b/BUGS
index 576785f..24c52b6 100644
--- a/BUGS
+++ b/BUGS
@@ -1,2 +1,8 @@
-# BUG: trash command in lf doesn't work with files which has spaces in them.
+# [FIXED] trash command in lf doesn't work with files which has spaces in them.
- Emergency: low
+
+# Using /tmp/noti.txt for notification is not secure
+- Emergency: moderate
+
+# Automatic slock build script causes problems
+- Emergency: moderate
diff --git a/README.md b/README.md
index 1e333a4..f0a5927 100644
--- a/README.md
+++ b/README.md
@@ -46,16 +46,14 @@ note: Some distros require installing `-devel` or `-dev` variants
## Program dependencies (optional but recommended)
- Xorg
-- dunst
-- fzf [useless]
+- fzf
- git
- lf >= r31
- mpv
-- libnotify (notify-send command)
- nsxiv or sxiv
- nvim >= 0.10.3 or vim
- picom
-- qutebrowser
+- firefox
- scrot
- setxkbmap
- xorg-xinit
diff --git a/TODO b/TODO
index ab50a25..2f858e0 100644
--- a/TODO
+++ b/TODO
@@ -4,6 +4,10 @@
[x] Test on Ubuntu
[x] Test on Void
+[] Verify installed files
+[] Install slock
+[x] in script only the name of the program should be given not the whole path
+[x] Fix bugs and overall polish before release
[x] Handle deamons
[x] unlock the gpg keys in login
[x] move the current wallpaper from ~/.config to ~/.cache
@@ -18,11 +22,10 @@
[x] update wallpaper script to use the .local/share directory
[x] update wallpaper script to have a symlink to the selected wallpaper
[x] add notification config to show on the middle screen
-[] Add BSD support
[x] Replace JetBrains Mono Nerd Font with a smaller alternative
[x] Send notification when battery is too low
-[] Verify installed files
[x] Unified library to send desktop notifications
[x] Add temporary turn-off for compositor to the `run` function in slib
[x] Enhance the `run` function
-[] Find a proper zoom application
+[x] Find a proper zoom application
+[x] add blur and current state to sslock as well as black screen
diff --git a/build.sh b/build.sh
index 3e3d7f0..76ea132 100644
--- a/build.sh
+++ b/build.sh
@@ -13,10 +13,11 @@ ZSHRC="${HOME}/.zshrc"
ZCACHE="${HOME}/.cache/zsh/history"
GITCONFIG="${HOME}/.gitconfig"
-dwm_version="dwm_farajli-6.5.2"
+dwm_version="dwm_farajli-6.5.3"
dmenu_version="dmenu_farajli-5.3.0"
slstatus_version="slstatus_farajli-1.0.1"
st_version="st_farajli-0.9.2.1"
+slock_version="slock_farajli-1.6.0"
MAKEDIR() { mkdir -pv "${1}"; }
@@ -44,7 +45,7 @@ pkg() {
"sync") curl -LO https://farajli.net/archive/"${package}".tar.gz ;;
"unpack") tar xf "${package}".tar.gz ;;
"compile") make -C "${package}" ;;
- "install") PREFIX="${BINDIR}" make -C "${package}" install ;;
+ "install") PREFIX=$(dirname "${BINDIR}") make -C "${package}" install ;;
"font_install") cp -r "${package}" "${FONTDIR}" ;;
?)
echo Invalid usage of pkg >&2
@@ -54,7 +55,7 @@ pkg() {
done
}
-clean() { rm -rf -- *.tar.gz LiberationMono "${dwm_version}" "${dmenu_version}" "${slstatus_version}" "${st_version}"; }
+clean() { rm -rf -- *.tar.gz LiberationMono "${dwm_version}" "${dmenu_version}" "${slstatus_version}" "${st_version}" "${slock_version}"; }
create_dirs() {
MAKEDIR "${BINDIR}"
@@ -126,3 +127,4 @@ install_dwm() { pkg "${dwm_version}" sync unpack install; }
install_st() { pkg "${st_version}" sync unpack install; }
install_dmenu() { pkg "${dmenu_version}" sync unpack install; }
install_slstatus() { pkg "${slstatus_version}" sync unpack install; }
+install_slock() { pkg "${slock_version}" sync unpack install; }
diff --git a/config/lf/lfrc b/config/lf/lfrc
index fcdbb03..c00135d 100644
--- a/config/lf/lfrc
+++ b/config/lf/lfrc
@@ -19,10 +19,10 @@ map zz :{{ set preview; set ratios 1:2:3; }}
# Directory change keybinds (some overwrite default ones)
# <c-h> and <c-k> might fail on some terminal emulators
-map <c-h> cd ~/
+map <c-e> cd ~/
map <c-p> cd ~/proj
-map <c-t> cd ~/tproj
-map <c-k> cd /tmp
+map <c-t> cd ~/tmp
+map <c-v> cd /tmp
map <c-w> cd ~/work
# Theme
diff --git a/config/shell/profile b/config/shell/profile
index d774568..f561eee 100644
--- a/config/shell/profile
+++ b/config/shell/profile
@@ -26,8 +26,8 @@ export PATH="${XDG_BIN_DIR}:${PATH}"
[ -x "$(command -v nvim)" ] && export EDITOR="nvim"
[ -x "$(command -v alacritty)" ] && export TERMINAL="alacritty"
[ -x "$(command -v st)" ] && export TERMINAL="st"
-[ -x "$(command -v firefox)" ] && export BROWSER="firefox"
[ -x "$(command -v qutebrowser)" ] && export BROWSER="qutebrowser"
+[ -x "$(command -v firefox)" ] && export BROWSER="firefox"
export MAKEFLAGS="-j8" # Reduce compile times
diff --git a/daemons/dcheck_battery b/daemons/dcheck_battery
index 627acbf..343bc4a 100755
--- a/daemons/dcheck_battery
+++ b/daemons/dcheck_battery
@@ -8,7 +8,7 @@ while true; do
# Only notify if battery is low AND not charging
if [ "${status}" = "Discharging" ] && [ "${percent}" -lt 7 ]; then
- nsend -c "Battery" "Critically low: ${percent}%"
+ nsend -s "Battery" "Critically low: ${percent}%"
fi
sleep 120
diff --git a/install b/install
index 50edd26..098654a 100755
--- a/install
+++ b/install
@@ -28,12 +28,14 @@ install_wallpapers
install_x11
install_zathura
install_gui_scripts
+install_daemons
# Suckless
install_dmenu
install_dwm
install_slstatus
install_st
+install_slock
# Arch Linux
# install_pacman
diff --git a/scripts/gui/nsend b/scripts/gui/nsend
index 80e1764..1bfc1f4 100755
--- a/scripts/gui/nsend
+++ b/scripts/gui/nsend
@@ -14,19 +14,21 @@ EOF
exit 0
}
-check_program "notify-send" "libnotify must be installed"
-
-case "${1}" in
-"-s")
- [ "${#}" -gt 3 ] && invalid_use
-
- shift
- eval $(printf 'notify-send "%s" "%s"' "${1}" "${2}")
-
- exit 0
+case "${#}" in
+1)
+ [ "${1}" = "-h" ] && help
+ invalid_use
+;;
+2)
+ [ "${1}" = "-s" ] || invalid_use
+ notification_string="${2}"
+;;
+3)
+ [ "${1}" = "-s" ] || invalid_use
+ notification_string="${2}: ${3}"
;;
-"-h") help ;;
-
*) invalid_use ;;
-
esac
+
+
+send_notification "${notification_string}"
diff --git a/scripts/gui/sclip b/scripts/gui/sclip
index 3666448..3d2caa5 100755
--- a/scripts/gui/sclip
+++ b/scripts/gui/sclip
@@ -18,12 +18,15 @@ exit 0
check_program "xclip"
i_flg=0
-while getopts "f:c:ih" option; do
+silent=0
+while getopts "f:c:sih" option; do
case "${option}" in
f) filepath="${OPTARG}" ;;
c) input="${OPTARG}" ;;
+ s) silent=1 ;;
+
i) i_flg=1 ;;
h) help ;;
@@ -38,6 +41,11 @@ shift $((OPTIND - 1))
if [ -n "${filepath}" ]; then
mime_type=$(file --mime-type -b "${filepath}")
+
+ if [ "${silent}" -eq 1 ]; then
+ run "xclip -selection clipboard -t ${mime_type} -i ${filepath}"
+ fi
+
run --success-notify "${filepath} copied" \
--failure-notify "${filepath} failed to copy" \
"xclip -selection clipboard -t ${mime_type} -i ${filepath}"
@@ -46,8 +54,17 @@ fi
[ "${i_flg}" -eq 1 ] && input=$(cat)
if [ -n "${input}" ]; then
+ # Don't use `run` since pipes are used
printf '%s' "${input}" | xclip -selection clipboard
- exit 0
+
+ if [ $? -eq 0 ]; then
+ [ "${silent}" -eq 0 ] && send_notification "${argv0}:" "'${input}' copied"
+ exit 0
+ fi
+
+ [ "${silent}" -eq 0 ] && send_notification "${argv0}:" "'${input}' failed to copy"
+
+ exit 1
fi
run "xclip -o -selection clipboard"
diff --git a/scripts/gui/sslock b/scripts/gui/sslock
index 0751de7..26ba2cf 100755
--- a/scripts/gui/sslock
+++ b/scripts/gui/sslock
@@ -4,7 +4,12 @@
help() {
cat << EOF
-${0}: Wrapper script to set lock the screen
+${0}: Wrapper script to take screenshots
+options:
+ -n Black screen
+ -b Blur
+ -c Take the current state of the desktop
+ -h Print this message and exit
EOF
exit 0
@@ -12,9 +17,43 @@ exit 0
check_program "slock"
-[ "${#}" -eq 1 ] && [ "${1}" = "-h" ] && help
+blur=0
+set_current_state=0
+current_wallpaper="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
+while getopts "bcnh" option; do
+ case "${option}" in
+ b)
+ check_program "mogrify" "imagemagick must be installed"
+ blur=1 ;;
-[ "${#}" != 0 ] && invalid_use
+ c)
+ check_program "scrot"
+ set_current_state=1
+ ;;
+ n)
+ slock
+ exit 0;;
-BACKGROUND="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
-slock -f "${BACKGROUND}"
+ h) help ;;
+
+ *) invalid_use -h ;;
+
+ esac
+done
+
+shift $((OPTIND - 1))
+
+[ "${#}" -eq 0 ] || invalid_use
+
+background="/tmp/$(date '+%b%d::%H%M%S').png"
+
+if [ "$set_current_state" -eq 0 ]; then
+ # Avoid distorting the wallpaper when calling `mogrify`
+ cp "${current_wallpaper}" "${background}"
+else
+ scrot -z "${background}"
+fi
+
+[ "${blur}" -eq 1 ] && mogrify -blur 0x8 "${background}"
+
+slock -f "${background}"
diff --git a/scripts/gui/swall b/scripts/gui/swall
index 9cb9e39..a225481 100755
--- a/scripts/gui/swall
+++ b/scripts/gui/swall
@@ -18,7 +18,6 @@ EOF
exit 0
}
-
check_program "xwallpaper"
SYMLINK="${XDG_CACHE_HOME:-$HOME/.cache}/wallpaper/current"
@@ -59,7 +58,7 @@ if [ -n "${input}" ]; then
fi
if [ -n "${waldir}" ]; then
- image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' 2>/dev/null \
+ image=$(find "${waldir}" -iregex '.*.\(jpg\|jpeg\|png\)' 2>/dev/null \
| shuf -n 1 )
fi
diff --git a/scripts/slib b/scripts/slib
index 0e0de36..4e21eb6 100755
--- a/scripts/slib
+++ b/scripts/slib
@@ -1,7 +1,6 @@
#!/bin/sh
-# Avoid using full paths instead only use the program names.
-argv0="${0}"
+argv0=$(basename "${0}")
# @FUNCTION: err
# @USAGE: [-x] <message> ...
@@ -14,7 +13,6 @@ argv0="${0}"
# This function is intended for fatal errors; it always exits the script.
# @EXAMPLE:
# err "Invalid usage" "Try '${argv0} -h' for help."
-
err() {
if [ "${1}" != "-x" ]; then
printf "%s: " "${argv0}"
@@ -61,21 +59,38 @@ check_program() {
err "${1} must be installed"
}
+# @FUNCTION: send_notification
+# @USAGE: send_notification <message> ...
+# @DESCRIPTION:
+# Write a notification message to a temporary file and trigger a dwm notification signal.
+# The message is written to /tmp/noti.txt. If writing fails, a warning is printed to stderr.
+# After writing, a dwm signal is sent using `xsetroot -name "fsignal:1"`.
+#
+# @EXAMPLE:
+# Send a desktop notification with the message "Backup complete".
+#
+# send_notification "Backup complete"
+
+send_notification() {
+ echo "$@" > /tmp/noti.txt || echo "Warning: failed to write to notification file" >&2
+ xsetroot -name "fsignal:1"
+}
+
# @FUNCTION: run
-# @USAGE: [--reload-status] [--reload-compositor] [--on-success <cmd>] [--on-failure <cmd>] <command> [success-msg] [failure-msg]
+# @USAGE: [--reload-status] [--reload-compositor] [--success-notify <msg>] [--failure-notify <msg>] <command> [success-msg] [failure-msg]
# @DESCRIPTION:
# Safely execute a simple shell command, print optional success/failure messages,
-# and optionally reload status bars or restart the compositor.
+# and optionally reload the status bar or restart the compositor.
#
# Success messages are printed to stdout; failure messages are printed to stderr.
-# To specify a failure message, a success message must also be provided.
+# Optional desktop notifications can be sent using --success-notify and --failure-notify.
# Command output is not suppressed.
#
# Options:
# --reload-status Reload the status bar (via `slreload`).
# --reload-compositor Restart the compositor (kills and restarts `picom`).
-# --on-success <cmd> Run another command if the main command succeeds.
-# --on-failure <cmd> Run another command if the main command fails.
+# --success-notify <msg> Send a desktop notification on success.
+# --failure-notify <msg> Send a desktop notification on failure.
#
# Restrictions:
# - Does NOT use `eval`; only simple commands and arguments are supported.
@@ -83,7 +98,7 @@ check_program() {
# - This design prevents unintended execution and makes the function safe in scripts.
#
# Return value:
-# 0 if the command succeeds, 1 otherwise.
+# Exits with 0 if the command succeeds, 1 otherwise.
#
# @EXAMPLES:
# # Run xwallpaper and print the image path on success
@@ -92,10 +107,10 @@ check_program() {
# # Restart compositor and show a success message
# run --reload-compositor "xwallpaper --zoom ${image}" "Wallpaper updated" "Wallpaper failed"
#
-# # With success and failure hooks
-# run --on-success "notify-send 'OK'" \
-# --on-failure "notify-send 'Failed'" \
-# "cp config config.bak" "Backup complete" "Backup failed"
+# # With notification hooks
+# run --success-notify "Wallpaper set" \
+# --failure-notify "Wallpaper failed" \
+# "xwallpaper --zoom ${image}" "Wallpaper updated" "Wallpaper failed"
run() {
relstat=0
@@ -105,8 +120,8 @@ run() {
case "$1" in
--reload-status) relstat=1 ;;
--reload-compositor) compstat=1 ;;
- --on-success) success_command="${2}"; shift ;;
- --on-failure) failure_command="${2}"; shift ;;
+ --success-notify) success_msg="${2}"; shift ;;
+ --failure-notify) failure_msg="${2}"; shift ;;
*) break;
esac
shift
@@ -118,10 +133,10 @@ run() {
if ${1}; then
[ -n "${2}" ] && echo "${2}"
- [ -n "${success_command}" ] && sh -c "${success_command}"
+ [ -n "${success_msg}" ] && send_notification "${argv0}:" "${success_msg}"
else
[ -n "${3}" ] && err "${3}"
- [ -n "${failure_command}" ] && sh -c "${failure_command}"
+ [ -n "${failure_msg}" ] && send_notification "${argv0}:" "${failure_msg}"
exit 1
fi