feat: add prayer timer to polybar

This commit is contained in:
Flinner Yuu 2024-11-14 16:21:29 +03:00
parent 2763a2059c
commit 6880a03eec
Signed by: flinner
GPG Key ID: 95CE0DA7F0E58CA6
9 changed files with 2101 additions and 1520 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
#xset r rate 400 100 xset r rate 180 40
##emacs -fs & ##emacs -fs &
rm -rf ~/.cache/fontconfig rm -rf ~/.cache/fontconfig
@ -25,6 +25,7 @@ source ~/.fehbg
(sleep 1 && warpd)& (sleep 1 && warpd)&
killall wired killall wired
(sleep 1 && wired ) & (sleep 1 && wired ) &
(sleep 3 && greenclip daemon) &
#(sleep 3 && optimus-manager-qt) & #(sleep 3 && optimus-manager-qt) &
(sleep 3 && flameshot) & (sleep 3 && flameshot) &
@ -32,7 +33,9 @@ killall wired
(sleep 6 && bspc rule -r KeePassXC ) & (sleep 6 && bspc rule -r KeePassXC ) &
(sleep 5 && syncthing -no-browser) & (sleep 5 && syncthing -no-browser) &
(sleep 100 && nextcloud --background) & (sleep 5 && kdeconnect-indicator) &
(sleep 4 && kdeconnectd) &
#(sleep 100 && nextcloud --background) &
#(sleep 5 && thunderbird ) & #(sleep 5 && thunderbird ) &
#(sleep 7 && bspc rule -r Thunderbird ) & #(sleep 7 && bspc rule -r Thunderbird ) &
@ -61,6 +64,12 @@ killall goimapnotify
# Japanses Input # Japanses Input
#(sleep 1 && fcitx -d ) & #(sleep 1 && fcitx -d ) &
(sleep 0 && ~/bin/keyboard ) & (sleep 0 && ~/bin/keyboard ) &
#(sleep 4 && ~/bin/battery-alert ) &
(sleep 1 && udiskie --tray) &
(sleep 1 && nm-applet) &
(sleep 2 && blueberry-tray) &
## Audio ## Audio
(sleep 0 && dbus-run-session pipewire ) & (sleep 0 && dbus-run-session pipewire ) &

354
bin/bin/prayer-times Executable file
View File

@ -0,0 +1,354 @@
#!/bin/bash
# ----- Parameters ------ #
# Coordinates: https://www.mapcoordinates.net/en
# Set explicitly, or leave commented to get them automatically from ipinfo.io
# lat='100.00000'
# long='100.00000'
# Calculation Method: https://api.aladhan.com/v1/methods
method='4'
# Print Text Language (en/ar)
print_lang="ar"
# Notifcation Daemon
notify="mako"
# ----------------------- #
prayers_json="$HOME/.local/share/prayers.json"
prayers=("Fajr" "Dhuhr" "Asr" "Maghrib" "Isha")
declare -A date
declare -A epochtimes
declare -A prayers_ar
prayers_ar=(
["Fajr"]="الفجر"
["Sunrise"]="الشروق"
["Dhuhr"]="الظهر"
["Asr"]="العصر"
["Maghrib"]="المغرب"
["Isha"]="العشاء"
)
date=(
[day_idx]=$(($(date +%-d) - 1))
[weekday]=$(date +%a)
[month]=$(date +%-m)
[year]=$(date +%Y)
)
nameof() {
if [[ "$print_lang" != "en" ]]; then
local array_name="prayers_$print_lang"
eval "echo -n \${${array_name}[$1]}"
else
echo -n "$1"
fi
}
check() {
local available_month
if [[ -r $prayers_json ]]; then
available_month=$(jq -r ".data[0].date.gregorian.month.number" "$prayers_json")
else
local fetch_prayers=1
fi
if [[ "$fetch_prayers" || "$available_month" != "${date[month]}" ]]; then
# Fetch the geolocation data from ipinfo.io
response=$(curl -s https://ipinfo.io)
echo "-- fetching latitude and longitude"
# Parse the latitude and longitude
location=$(echo $response | jq -r '.loc')
# Separate latitude and longitude
latitude=$(echo $location | cut -d',' -f1)
longitude=$(echo $location | cut -d',' -f2)
# Set `lat` to `latitude`, or default to the specified value above
lat=${latitude:lat}
long=${longitude:long}
echo "-- latitude: ${lat}, longitude: ${long}"
echo "-- fetching current month prayer calendar (${date[month]}-${date[year]})"
# Documentation: https://aladhan.com/prayer-times-api#GetCalendar
curl -Lso "$prayers_json" "https://api.aladhan.com/v1/calendar/${date[year]}/${date[month]}?latitude=$lat&longitude=$long&method=$method"
fi
}
add-jobs() {
# WARNING: THIS SCRIPTS REMOVES ALL JOBS IN QUEUE "P" SCHEDULED USING AT (ADJUST ACCORDINGLY)
echo "-- removing all jobs in queue 'p'"
if [[ "$(at -q p -l | wc -l)" != "0" ]]; then
for i in $(at -q p -l | awk '{ print $1 }'); do
atrm "$i"
done
fi
for prayer in "${prayers[@]}"; do
echo "-- creating at job for $prayer prayer"
if [[ "$notify" == "mako" ]]; then
printf 'notify-send -t 30000 --icon="clock-applet-symbolic" "Prayer Times" "It is time for %s prayer 🕌"' "$prayer" | at -q p "$(timeof "$prayer" '%H:%M %F')"
else
printf '[ "$(dunstify --icon="clock-applet-symbolic" --action="Reply,reply" "Prayer Times" "Time for %s prayer 🕌" -t 30000)" = "2" ] && %s' "$prayer" "$HOME/.local/bin/toggle-athan" | at -q p "$(timeof "$prayer" '%H:%M %F')"
fi
done
}
timeof() {
[[ "$#" -lt "1" ]] && echo "atleast 1 argument is needed" && return 1
echo -n "$(date -d "$(jq -r ".data[${date[day_idx]}].timings.$1" "$prayers_json")" "+${2:-%I:%M}")"
}
hijri() {
case "$1" in
weekday)
if [[ "$print_lang" == "ar" ]]; then
echo -n "$(jq -r ".data[${date[day_idx]}].date.hijri.weekday.ar" "$prayers_json")"
else
echo -n "$(jq -r ".data[${date[day_idx]}].date.hijri.weekday.en" "$prayers_json")"
fi
;;
day)
echo -n "$(jq -r ".data[${date[day_idx]}].date.hijri.day" "$prayers_json")"
;;
month)
if [[ "$print_lang" == "ar" ]]; then
echo -n "$(jq -r ".data[${date[day_idx]}].date.hijri.month.ar" "$prayers_json")"
else
echo -n "$(jq -r ".data[${date[day_idx]}].date.hijri.month.en" "$prayers_json")"
fi
;;
year)
echo -n "$(jq -r ".data[${date[day_idx]}].date.hijri.year" "$prayers_json")"
;;
*)
echo "unsupported argument: $1" && return 1
;;
esac
}
settimes() {
# return if array already populated
[[ "${#epochtimes[@]}" -gt 0 ]] && return 0
epochtimes=(
[now]=$(date +%s)
[fajr]=$(timeof Fajr %s)
[dhuhr]=$(timeof Dhuhr %s)
[asr]=$(timeof Asr %s)
[maghrib]=$(timeof Maghrib %s)
[isha]=$(timeof Isha %s)
)
local nxt_idx=0
local curr_idx=4
for i in {4..0}; do
local prayer_key="${prayers[$i],,}"
if [[ "${epochtimes[now]}" -ge "${epochtimes[$prayer_key]}" ]]; then
[[ "$i" -lt "4" ]] && curr_idx=$i && nxt_idx=$((i + 1))
break
fi
done
local next_key="${prayers[$nxt_idx],,}"
epochtimes[next]="${epochtimes[$next_key]}"
currentprayer="${prayers[$curr_idx]}"
nextprayer="${prayers[$nxt_idx]}"
if [[ "$nxt_idx" == "1" && "${date[weekday]}" == "Fri" ]]; then
nextprayer="Jumuaa"
fi
}
timeto() {
[[ "$#" -lt "1" ]] && echo "atleast 1 argument are needed" && return 1
settimes
remain="$((epochtimes["${1,,}"] - epochtimes[now]))"
[[ "$remain" -lt "0" ]] && remain="$((remain + 86400))"
date -u -d"@$remain" "+${2:-%H:%M}"
}
print() {
local format="📅 %s،%s\n%-12s%-10s\n%-12s%-10s\n%-12s%-10s\n%-12s%-10s\n%-12s%-10s\n%-12s%-10s\n"
if [[ "$print_lang" == "ar" ]]; then
format="📅 %s،%s\n%s%11s\n%s%10s\n%s%11s\n%s%11s\n%s%10s\n%s%10s\n"
fi
printf "$format" \
"$(hijri weekday)" \
"$(hijri day)-$(hijri month)-$(hijri year)" \
"۞ $(nameof Fajr)" "$(timeof Fajr)" \
"۞ $(nameof Sunrise)" "$(timeof Sunrise)" \
"۞ $(nameof Dhuhr)" "$(timeof Dhuhr)" \
"۞ $(nameof Asr)" "$(timeof Asr)" \
"۞ $(nameof Maghrib)" "$(timeof Maghrib)" \
"۞ $(nameof Isha)" "$(timeof Isha)"
}
yad-en() {
yad \
--text-width=10 \
--on-top \
--text \
"<span font-size='large'><b>📅 $(hijri weekday),$(hijri day)-$(hijri month)-$(hijri year)</b></span>" \
--list \
--width=300 \
--posx=550 \
--posy=20 \
--height=270 \
--title="Prayers" \
--column="Prayer" \
--column="Time" \
--expand-column=1 \
--no-buttons \
--no-click \
--no-selection \
"<span font-size='large'>$(nameof Fajr)</span>" "<span font-size='large'>$(timeof Fajr)</span>" \
"<span font-size='large'>$(nameof Sunrise)</span>" "<span font-size='large'>$(timeof Sunrise)</span>" \
"<span font-size='large'>$(nameof Dhuhr)</span>" "<span font-size='large'>$(timeof Dhuhr)</span>" \
"<span font-size='large'>$(nameof Asr)</span>" "<span font-size='large'>$(timeof Asr)</span>" \
"<span font-size='large'>$(nameof Maghrib)</span>" "<span font-size='large'>$(timeof Maghrib)</span>" \
"<span font-size='large'>$(nameof Isha)</span>" "<span font-size='large'>$(timeof Isha)</span>"
}
yad-ar() {
yad \
--text-width=10 \
--on-top \
--text-align='right' \
--text \
"<span font-size='large'><b>📅 $(hijri weekday),$(hijri day)-$(hijri month)-$(hijri year)</b></span>" \
--list \
--width=250 \
--posx=550 \
--posy=20 \
--height=280 \
--title="Prayers" \
--column="الوقت" \
--column="الصلاة" \
--expand-column=1 \
--no-buttons \
--no-click \
--no-selection \
"<span font-size='large'>$(timeof Fajr)</span>" "<span font-size='large'>$(nameof Fajr)</span>" \
"<span font-size='large'>$(timeof Sunrise)</span>" "<span font-size='large'>$(nameof Sunrise)</span>" \
"<span font-size='large'>$(timeof Dhuhr)</span>" "<span font-size='large'>$(nameof Dhuhr)</span>" \
"<span font-size='large'>$(timeof Asr)</span>" "<span font-size='large'>$(nameof Asr)</span>" \
"<span font-size='large'>$(timeof Maghrib)</span>" "<span font-size='large'>$(nameof Maghrib)</span>" \
"<span font-size='large'>$(timeof Isha)</span>" "<span font-size='large'>$(nameof Isha)</span>"
}
yad-toggle() {
local yad_pid
yad_pid=$(pgrep -f 'yad.*Prayers')
if [[ -z "$yad_pid" ]]; then
if [[ "$print_lang" == "ar" ]]; then
yad-ar
else
yad-en
fi
else
kill "$yad_pid"
fi
}
current() {
settimes
echo "$currentprayer"
}
next() {
settimes
echo "$nextprayer"
}
remaining() {
settimes
timeto next "%H:%M:%S"
}
status() {
settimes
local remain
remain="$(timeto next)"
echo "$nextprayer in $remain"
}
waybar-status() {
settimes
local remain
remain="$(timeto next)"
local next_text="$nextprayer in $remain"
printf '{ "text": "%s", "class": "%s" }' "$next_text" "$nextprayer"
}
case "$1" in
check)
check
;;
jobs)
add-jobs
;;
sync)
check
add-jobs
;;
print)
print
;;
current)
current
;;
next)
next
;;
remaining)
remaining
;;
status)
status
;;
yad)
yad-toggle
;;
waybar)
waybar-status
;;
timeto)
if [[ -n "$2" ]]; then
if [[ "$2" == "next" ]]; then
valid=1
else
for p in "${prayers[@]}"; do
if [[ "${2^}" == "$p" ]]; then
valid=1
break
fi
done
fi
fi
if [[ -z "$valid" ]]; then
IFS='|'
echo "Usage: $(basename "$0") timeto (next|${prayers[*],,})"
exit 1
fi
timeto "$2"
;;
*)
echo "Usage: $(basename "$0") [command]"
echo "Command:"
echo " check Check if prayer time data needs to be fetched"
echo " jobs Add prayer time notifications as at jobs"
echo " sync Check and sync prayer time data, and add notifications"
echo " print Print prayer times"
echo " current Get the current prayer"
echo " next Get the next prayer"
echo " remaining Get the remaining time for the next prayer"
echo " status Get the status message indicating the next prayer"
echo " timeto Get the time remaining for a prayer"
echo " yad Toggle the yad window showing prayer times"
echo " waybar Print waybar JSON-formatted status"
exit 1
;;
esac

View File

@ -44,7 +44,9 @@ import subprocess
commands = ['isbn to bibtex', commands = ['isbn to bibtex',
'emoji', 'emoji',
'c'] 'calc',
'spellcheck',
'nvidia rofi']
rofi_process = subprocess.Popen(['rofi', '-dmenu'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True) rofi_process = subprocess.Popen(['rofi', '-dmenu'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True)
@ -58,12 +60,20 @@ if selected_command:
clipboard = read_clipboard() clipboard = read_clipboard()
isbn = bash_it(f"echo \"{clipboard}\n'Esc to Cancel'\" | rofi -dmenu") isbn = bash_it(f"echo \"{clipboard}\n'Esc to Cancel'\" | rofi -dmenu")
exit(0) if not isbn else False exit(0) if not isbn else False
isbn = isbn.replace("\n", ",") isbn = isbn.replace("\n", " ")
eprint("isbn:", isbn)
res = bash_it('echo ' + isbn + '| isbn_to_bibtex.py') res = bash_it('echo ' + isbn + '| isbn_to_bibtex.py')
eprint(res)
write_to_clipboard(res) write_to_clipboard(res)
send_notif("status", "done!: "+ res) send_notif("status", "done!: "+ res)
elif selected_command == 'emoji': elif selected_command == 'emoji':
bash_it("rofi -show emoji") bash_it("rofi -show emoji")
elif selected_command == 'calc':
bash_it("rofi -show calc -modi calc -no-show-match -no-sort")
elif selected_command == 'spellcheck':
bash_it("rofi -show spell -modes \"spell:rofi-spellcheck.sh\"")
elif selected_command == 'nvidia rofi':
bash_it("nvidia-offload ~/.config/polybar/forest/scripts/launcher.sh")
else: else:
send_notif("Failure", "Unkown Command") send_notif("Failure", "Unkown Command")
exit(1) exit(1)

View File

@ -8,7 +8,7 @@ pgrep ~/bin/wm/bspswallow || ~/bin/wm/bspswallow &
# not sure if I can count using Roman Numerals :) # not sure if I can count using Roman Numerals :)
bspc monitor -d I II III IV V VI VII VIII IX X bspc monitor eDP1 -d I II III IV V VI VII VIII IX X
#bspc config ignore_ewmh_fullscreen all #bspc config ignore_ewmh_fullscreen all
bspc config ignore_ewmh_focus true bspc config ignore_ewmh_focus true
@ -27,18 +27,24 @@ bspc config single_monocle true
bspc config focus_follows_pointer true bspc config focus_follows_pointer true
bspc config pointer_follows_focus true bspc config pointer_follows_focus true
bspc config remove_unplugged_monitors true
bspc config remove_disabled_monitors true
# bspc rule -a Gimp desktop='^8' state=floating follow=on # bspc rule -a Gimp desktop='^8' state=floating follow=on
#bspc rule -a Chromium desktop='^1' #bspc rule -a Chromium desktop='^1'
# these 2 rules are removed after the program starts, in ~/bin/autostart # these 2 rules are removed after the program starts, in ~/bin/autostart
bspc rule -a Thunderbird desktop='^8' bspc rule -a Thunderbird desktop='^8'
bspc rule -a KeePassXC desktop='^8' bspc rule -a KeePassXC desktop='^9'
# the confirm dialog # the confirm dialog
bspc rule -a "KeePassXC:*:Confirm Auto-Type" sticky=on bspc rule -a "keepassxc:*:Confirm Auto-Type" sticky=on
bspc rule -a "Dragon-drop" sticky=on bspc rule -a "Dragon-drop" sticky=on
bspc rule -a "No Title Yet:*:*" state=floating # for ngscopeclient
bspc rule -a "*:*:Quick Format Citation" state=floating # for ngscopeclient
bspc rule -a Dino desktop='^8' bspc rule -a Dino desktop='^8'
bspc rule -a Peek state=floating bspc rule -a Peek state=floating
bspc rule -a Qalculate-gtk state=floating
bspc rule -a Connman-gtk state=floating bspc rule -a Connman-gtk state=floating
bspc rule -a mplayer2 state=floating bspc rule -a mplayer2 state=floating
bspc rule -a Emacs state=tiled bspc rule -a Emacs state=tiled
@ -50,6 +56,11 @@ bspc rule -a wmpin sticky=on
bspc rule -a Floating state=floating bspc rule -a Floating state=floating
bspc rule -a \*:\*:org-capture state=floating bspc rule -a \*:\*:org-capture state=floating
# Fix MATLAB https://github.com/baskerville/bspwm/issues/1204
#bspc rule -a 'MATLAB R2024a - academic use:sun-awt-X11-XWindowPeer:DefaultOverlayManager.JWindow' manage=off
#bspc rule -a 'MATLAB R2024a - academic use:sun-awt-X11-XWindowPeer:TabCompletionPopup' manage=off
bspc rule -a 'MATLAB*:TabCompletionPopup' manage=off
bspc rule -a 'MATLAB*:DefaultOverlayManager.JWindow' manage=off
~/bin/autostart ~/bin/autostart
xsetroot -cursor_name left_ptr & xsetroot -cursor_name left_ptr &

View File

@ -82,6 +82,7 @@ remove warning by use-package
(setq use-dialog-box nil) ; I don't like to confirm anything with a mouse! (setq use-dialog-box nil) ; I don't like to confirm anything with a mouse!
(defalias 'yes-or-no-p 'y-or-n-p) ; I don't want to type 'yes' everytime!, 'y' is enough (defalias 'yes-or-no-p 'y-or-n-p) ; I don't want to type 'yes' everytime!, 'y' is enough
;(setq native-comp-deferred-compilation t); emacs 30+ i guess
(setq comp-deferred-compilation-deny-list '()) ;; turn off bytecompiler warnings (setq comp-deferred-compilation-deny-list '()) ;; turn off bytecompiler warnings
(setq native-comp-async-report-warnings-errors nil) (setq native-comp-async-report-warnings-errors nil)
@ -220,7 +221,7 @@ Center text in the frame, looks nice ;)
:hook (prog-mode . olivetti-mode) :hook (prog-mode . olivetti-mode)
:hook (Info-mode . olivetti-mode) :hook (Info-mode . olivetti-mode)
:config :config
(setq olivetti-body-width 120)) (setq-default olivetti-body-width 120))
#+end_src #+end_src
@ -599,7 +600,6 @@ Capture
(define-key evil-insert-state-map "\C-b" 'evil-backward-char) (define-key evil-insert-state-map "\C-b" 'evil-backward-char)
(define-key evil-visual-state-map "\C-b" 'evil-backward-char) (define-key evil-visual-state-map "\C-b" 'evil-backward-char)
(define-key evil-insert-state-map "\C-d" 'evil-delete-char) (define-key evil-insert-state-map "\C-d" 'evil-delete-char)
(define-key evil-normal-state-map "\C-i" 'evil-jump-forward) (define-key evil-normal-state-map "\C-i" 'evil-jump-forward)
@ -679,7 +679,6 @@ Capture
(key-chord-define evil-insert-state-map "jk" 'evil-normal-state) (key-chord-define evil-insert-state-map "jk" 'evil-normal-state)
(key-chord-define evil-replace-state-map "jk" 'evil-normal-state)) (key-chord-define evil-replace-state-map "jk" 'evil-normal-state))
;; (use-package evil-escape ;; (use-package evil-escape
;; :after evil ;; :after evil
;; :init ;; :init
@ -1010,7 +1009,7 @@ Capture Templates
#+end_src #+end_src
*** COMMENT Visual Fill (center) *** COMMENT Visual Fill (center)
I know use olivetti mode, this code block is ignored! I now use olivetti mode, this code block is ignored!
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
(defun my/org-mode/org-mode-visual-fill () (defun my/org-mode/org-mode-visual-fill ()
(interactive) (interactive)
@ -1153,7 +1152,8 @@ From: https://yiufung.net/post/anki-org/
*** Customizations *** Customizations
#+begin_src emacs-lisp #+begin_src emacs-lisp
;;laggy :( ;;laggy :(
(setq org-agenda-show-outline-path nil) (setq org-agenda-show-outline-path nil
org-deadline-warning-days 30)
#+end_src #+end_src
*** T/ODOs *** T/ODOs
@ -1168,6 +1168,15 @@ From: https://yiufung.net/post/anki-org/
org-agenda-weekend-days '(5 6)) org-agenda-weekend-days '(5 6))
#+end_src #+end_src
*** Weeks per semester
#+begin_src emacs-lisp
(defun org-week-to-class-week (week)
(- week 34))
(advice-add 'org-days-to-iso-week :filter-return
#'org-week-to-class-week)
#+end_src
*** Go EVIL! *** Go EVIL!
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(eval-after-load 'org-agenda (eval-after-load 'org-agenda
@ -1191,6 +1200,8 @@ From: https://yiufung.net/post/anki-org/
"s" 'org-agenda-schedule "s" 'org-agenda-schedule
"d" 'org-agenda-deadline "d" 'org-agenda-deadline
"p" 'org-agenda-priority "p" 'org-agenda-priority
"+" 'org-agenda-priority-up
"-" 'org-agenda-priority-down
"t" 'org-agenda-todo "t" 'org-agenda-todo
"T" 'counsel-org-tag "T" 'counsel-org-tag
":" 'org-agenda-set-tags ":" 'org-agenda-set-tags
@ -1224,10 +1235,8 @@ From: https://yiufung.net/post/anki-org/
;;;; cool but inactive ;;;; cool but inactive
;; "gj" 'org-agenda-goto-date ;; "gj" 'org-agenda-goto-date
;; "gJ" 'org-agenda-clock-goto ;; "gJ" 'org-agenda-clock-goto
;; "gm" 'org-agenda-bulk-mark "gm" 'org-agenda-bulk-mark
;; "go" 'org-agenda-open-link "go" 'org-agenda-open-link
;; "+" 'org-agenda-priority-up
;; "-" 'org-agenda-priority-down
;; "y" 'org-agenda-todo-yesterday ;; "y" 'org-agenda-todo-yesterday
;; "n" 'org-agenda-add-note ;; "n" 'org-agenda-add-note
;; ";" 'org-timer-set-timer ;; ";" 'org-timer-set-timer
@ -1298,17 +1307,20 @@ From: https://yiufung.net/post/anki-org/
(:name "S" (:name "S"
:order 97 :order 97
:tag ("S")) :tag ("S"))
(:name "Life"
:order 97
:tag ("L"))
(:name "Habits" (:name "Habits"
:order 98 :order 98
:habit t) :habit t)
(:name "Overdue"
:deadline past
:scheduled past)
(:name "Today" ; today is what (:name "Today" ; today is what
:time-grid t ; Items that appear on the time grid :time-grid t ; Items that appear on the time grid
:scheduled today) :scheduled today)
(:name "Now" ; today is what (:name "Now" ; today is what
:todo "NOW") :todo "NOW")
(:name "Overdue"
:deadline past
:scheduled past)
(:name "Deadlines" (:name "Deadlines"
:deadline t) :deadline t)
(:name "To Refile" (:name "To Refile"
@ -1392,7 +1404,6 @@ From: https://yiufung.net/post/anki-org/
:super-groups 'org-super-agenda-groups :super-groups 'org-super-agenda-groups
:title "Quick Picks"))))) :title "Quick Picks")))))
#+end_src #+end_src
*** COMMENT org-timeblock *** COMMENT org-timeblock
@ -1404,7 +1415,7 @@ From: https://yiufung.net/post/anki-org/
#+end_src #+end_src
*** org-hyperscheduler *** COMMENT org-hyperscheduler
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package org-hyperscheduler (use-package org-hyperscheduler
:straight :straight
@ -1624,6 +1635,7 @@ Counsel Projectile
#+end_src #+end_src
*** lsp performance *** lsp performance
This is done in Performance section
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
(setq gc-cons-threshold 100000000) ;; 100 mb (setq gc-cons-threshold 100000000) ;; 100 mb
(setq read-process-output-max (* 1024 4024)) ;; 4mb (setq read-process-output-max (* 1024 4024)) ;; 4mb
@ -1705,7 +1717,7 @@ Lsp UI
:hook (prog-mode . origami-mode)) :hook (prog-mode . origami-mode))
#+end_src #+end_src
*** Formatting *** COMMENT Formatting
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package format-all (use-package format-all
;; :commands (format-all-mode) ;; :commands (format-all-mode)
@ -1773,7 +1785,6 @@ Magit TODOs!
(define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] nil nil 'bottom) (define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] nil nil 'bottom)
:ensure t) :ensure t)
#+end_src #+end_src
** Treemacs ** Treemacs
@ -1928,7 +1939,9 @@ Auto format
*** Haskell *** Haskell
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package haskell-mode :defer t) (use-package haskell-mode
:defer t
:config (require 'lsp-haskell))
#+end_src #+end_src
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -1946,6 +1959,7 @@ Auto format
(prog-mode . electric-pair-local-mode) (prog-mode . electric-pair-local-mode)
(haskell-mode . my/font/pretty-lambdas-haskell) (haskell-mode . my/font/pretty-lambdas-haskell)
(haskell-mode . flymake-mode)
:config :config
(haskell-indentation-mode -1) (haskell-indentation-mode -1)
(add-hook 'before-save-hook 'lsp-format-buffer) (add-hook 'before-save-hook 'lsp-format-buffer)
@ -2130,7 +2144,7 @@ Sbt for sbt commands...
*** LaTeX *** LaTeX
AucTex AucTex
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
;; latexmk ;; latexmk
(use-package magic-latex-buffer (use-package magic-latex-buffer
:custom (magic-latex-buffer 1) :custom (magic-latex-buffer 1)
@ -2145,7 +2159,6 @@ AucTex
(use-package company-reftex (use-package company-reftex
:after company) :after company)
;; use cdlatex ;; use cdlatex
(use-package cdlatex (use-package cdlatex
:defer t) :defer t)
@ -2157,7 +2170,6 @@ AucTex
:straight auctex :straight auctex
:defer t :defer t
:custom :custom
(olivetti-body-width 120)
(cdlatex-simplify-sub-super-scripts nil) (cdlatex-simplify-sub-super-scripts nil)
(reftex-default-bibliography (reftex-default-bibliography
'("~/Documents/refs.bib")) '("~/Documents/refs.bib"))
@ -2243,7 +2255,7 @@ AucTex
#+end_src #+end_src
Custom functions Custom functions
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(defun try/latex-mode-setup () (defun try/latex-mode-setup ()
(require 'company-reftex) (require 'company-reftex)
@ -2262,7 +2274,7 @@ Custom functions
Insert from clip Insert from clip
[[https://hershsingh.net/blog/emacs-latex-screenshot/#:~:text=Clipboard%20to%20TeX,-Finally%2C%20I%20have&text=Once%20I%20have%20captured%20the,file%20img%2F.][Quickly insert hand-drawn figures in a LaTeX document in Emacs]] [[https://hershsingh.net/blog/emacs-latex-screenshot/#:~:text=Clipboard%20to%20TeX,-Finally%2C%20I%20have&text=Once%20I%20have%20captured%20the,file%20img%2F.][Quickly insert hand-drawn figures in a LaTeX document in Emacs]]
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(defvar latex/insert-image-format "\\begin{center}\\includegraphics[width=\\linewidth]{%s}\\end{center}") (defvar latex/insert-image-format "\\begin{center}\\includegraphics[width=\\linewidth]{%s}\\end{center}")
(defvar latex/insert-figure-format (defvar latex/insert-figure-format
" \\begin{figure}[h] " \\begin{figure}[h]
@ -2307,7 +2319,6 @@ Insert from clip
;; Insert the latex snippet to include the figure ;; Insert the latex snippet to include the figure
(insert (format latex/insert-figure-format (concat "img/" (file-name-nondirectory (concat image-name ".png"))))))) (insert (format latex/insert-figure-format (concat "img/" (file-name-nondirectory (concat image-name ".png")))))))
#+end_src #+end_src
Folding Folding
@ -2346,7 +2357,7 @@ Folding
#+end_src #+end_src
ivy bibtex ivy bibtex
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(use-package ivy-bibtex (use-package ivy-bibtex
:defer t :defer t
:custom :custom
@ -2359,7 +2370,106 @@ ivy bibtex
#+end_src #+end_src
*** Verilog #+begin_src emacs-lisp
(use-package lsp-latex
:hook ((tex-mode . lsp)
(latex-mode . lsp)))
#+end_src
*** COMMENT Ledger
Unused, switched to =hledger=
#+begin_src emacs-lisp
(use-package ledger-mode
;; :mode ("\\.dat\\'" "\\.ledger\\'")
:mode ("\\.ledger\\'")
:bind (:map ledger-mode-map
("C-x C-s" . my/ledger-save))
:custom (ledger-clear-whole-transactions t)
:hook ((ledger-mode . flycheck-mode)
(ledger-mode . flyspell-mode))
:config
;(add-hook 'ledger-mode-hook (lambda () (add-hook 'before-save-hook 'ledger-mode-clean-buffer)))
)
(use-package flycheck-ledger :after ledger-mode)
#+end_src
*** hledger
#+begin_src emacs-lisp
(use-package hledger-mode
:mode ("\\.journal\\'" "\\.hledger\\'")
;:commands hledger-enable-reporting
:preface
(defun hledger/next-entry ()
"Move to next entry and pulse."
(interactive)
(hledger-next-or-new-entry)
(hledger-pulse-momentary-current-entry))
(defface hledger-warning-face
'((((background dark))
:background "Red" :foreground "White")
(((background light))
:background "Red" :foreground "White")
(t :inverse-video t))
"Face for warning"
:group 'hledger)
(defun hledger/prev-entry ()
"Move to last entry and pulse."
(interactive)
(hledger-backward-entry)
(hledger-pulse-momentary-current-entry))
:bind (("C-c j" . hledger-run-command)
:map hledger-mode-map
("C-c e" . hledger-jentry)
("M-p" . hledger/prev-entry)
("M-n" . hledger/next-entry))
:init
(setq hledger-jfile (expand-file-name "~/Documents/ledger/data_2024.hledger")
hledger-currency-string "SAR"
;hledger-email-secrets-file (expand-file-name "secrets.el" emacs-assets-directory)
)
;; Expanded account balances in the overall monthly report are
;; mostly noise for me and do not convey any meaningful information.
(setq hledger-show-expanded-report nil)
(when (boundp 'my-hledger-service-fetch-url)
(setq hledger-service-fetch-url
my-hledger-service-fetch-url))
:config
(require 'hledger-input)
(add-hook 'hledger-view-mode-hook #'hl-line-mode)
;(add-hook 'hledger-view-mode-hook #'center-text-for-reading)
(add-hook 'hledger-view-mode-hook
(lambda ()
(run-with-timer 1
nil
(lambda ()
(when (equal hledger-last-run-command
"balancesheet")
;; highlight frequently changing accounts
(highlight-regexp "^.*\\(savings\\|cash\\).*$")
(highlight-regexp "^.*credit-card.*$"
'hledger-warning-face))))))
(add-hook 'hledger-mode-hook
(lambda ()
(make-local-variable 'company-backends)
(add-to-list 'company-backends 'hledger-company))))
#+end_src
#+begin_src emacs-lisp
(use-package flycheck-hledger
:after (flycheck hledger-mode)
:demand t)
#+end_src
*** COMMENT Verilog
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq verilog-linter "verilator --lint-only") (setq verilog-linter "verilator --lint-only")
@ -2370,8 +2480,8 @@ ivy bibtex
(add-hook 'verilog-mode-hook 'electric-pair-mode) (add-hook 'verilog-mode-hook 'electric-pair-mode)
(add-hook 'verilog-mode-hook 'lsp) (add-hook 'verilog-mode-hook 'lsp)
(add-hook 'verilog-mode-hook 'flycheck-mode) (add-hook 'verilog-mode-hook 'flycheck-mode)
;; (add-hook 'verilog-mode-hook (lambda () (add-hook 'verilog-mode-hook (lambda ()
;; (add-hook 'before-save-hook 'verilog-indent-buffer nil t))) (add-hook 'before-save-hook 'verilog-indent-buffer nil t)))
(with-eval-after-load 'lsp-mode (with-eval-after-load 'lsp-mode
(add-to-list 'lsp-language-id-configuration '(verilog-mode . "verilog")) (add-to-list 'lsp-language-id-configuration '(verilog-mode . "verilog"))
@ -2380,9 +2490,41 @@ ivy bibtex
:major-modes '(verilog-mode) :major-modes '(verilog-mode)
:server-id 'verible-ls))) :server-id 'verible-ls)))
#+end_src #+end_src
*** SystemVerilog
#+begin_src emacs-lisp
(use-package verilog-ext
:hook ((verilog-mode . verilog-ext-mode)
(verilog-ext-mode . electric-pair-local-mode)
(verilog-ext-mode . lsp-mode))
:init
;; Can also be set through `M-x RET customize-group RET verilog-ext':
;; Comment out/remove the ones you do not need
(setq verilog-ext-feature-list
'(font-lock
xref
capf
hierarchy
eglot
lsp
;lsp-bridge
;lspce
flycheck
beautify
navigation
template
formatter
compilation
imenu
which-func
hideshow
typedefs
time-stamp
block-end-comments
ports))
:config
(verilog-ext-mode-setup))
#+end_src
*** VHDL *** VHDL
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq lsp-vhdl-server 'vhdl-ls) (setq lsp-vhdl-server 'vhdl-ls)
@ -2429,7 +2571,6 @@ ivy bibtex
vc-handled-backends '())))) vc-handled-backends '()))))
#+end_src #+end_src
* Misc * Misc
@ -2880,6 +3021,7 @@ I wrote that, neat isn't it? :P
;;Fixing duplicate UID errors when using mbsync and mu4e ;;Fixing duplicate UID errors when using mbsync and mu4e
#+end_src #+end_src
** Email List here! ** Email List here!
#+begin_src emacs-lisp :tangle no #+begin_src emacs-lisp :tangle no
;; This is a sample, it doesn't get included in init.el ;; This is a sample, it doesn't get included in init.el
@ -2942,6 +3084,29 @@ I prefer text/plain, over everything >:)
(add-to-list 'mm-discouraged-alternatives "text/html")) (add-to-list 'mm-discouraged-alternatives "text/html"))
#+end_src #+end_src
[[https://github.com/djcb/mu/issues/2665#issuecomment-2016826822][djcb/mu#2665 {mu4e rfe} Switch between "Reply" and "Wide Reply"]]
Supersede rather than reply to my own emails.
Only ask whether to reply to all if there are more than one recipients
#+begin_src emacs-lisp
(with-eval-after-load 'mu4e
(defun mu4e-supersede-or-compose-reply-ask-wide ()
"Supersede own messages or ask whether to reply-to-all."
(interactive)
(if (mu4e-message-contact-field-matches-me (mu4e-message-at-point) :from)
(mu4e-compose-supersede)
(let ((tos (length (mu4e-message-field-at-point :to)))
(ccs (length (mu4e-message-field-at-point :cc))))
(mu4e-compose-reply
(and (> (+ tos ccs) 1)
(yes-or-no-p "Reply to all?")))))
(evil-define-key 'normal mu4e-headers-mode-map "R" 'mu4e-supersede-or-compose-reply-ask-wide)
(evil-define-key 'normal mu4e-view-mode-map "R" 'mu4e-supersede-or-compose-reply-ask-wide))
#+end_src
** Send email (msmtp) ** Send email (msmtp)
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq sendmail-program (executable-find "msmtp") ;"/usr/bin/msmtp" (setq sendmail-program (executable-find "msmtp") ;"/usr/bin/msmtp"
@ -3026,3 +3191,6 @@ I prefer text/plain, over everything >:)
(setq dashboard-projects-switch-function 'counsel-projectile-switch-project-by-name)) (setq dashboard-projects-switch-function 'counsel-projectile-switch-project-by-name))
#+end_src #+end_src
# Local Variables:
# org-highlight-latex-and-related: nil
# End:

View File

@ -1,6 +1,6 @@
# Beware! This file is rewritten by htop when settings are changed in the interface. # Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly. # The parser is also very primitive, and not human-friendly.
htop_version=3.2.2 htop_version=3.3.0
config_reader_min_version=3 config_reader_min_version=3
fields=0 48 17 18 38 39 40 2 46 47 49 1 fields=0 48 17 18 38 39 40 2 46 47 49 1
hide_kernel_threads=1 hide_kernel_threads=1
@ -39,25 +39,25 @@ column_meter_modes_0=1 1 1 4 3
column_meters_1=RightCPUs2 Tasks LoadAverage Uptime DiskIO column_meters_1=RightCPUs2 Tasks LoadAverage Uptime DiskIO
column_meter_modes_1=1 2 2 4 3 column_meter_modes_1=1 2 2 4 3
tree_view=0 tree_view=0
sort_key=47 sort_key=46
tree_sort_key=0 tree_sort_key=0
sort_direction=-1 sort_direction=-1
tree_sort_direction=1 tree_sort_direction=1
tree_view_always_by_pid=0 tree_view_always_by_pid=0
all_branches_collapsed=0 all_branches_collapsed=0
screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command
.sort_key=PERCENT_MEM .sort_key=PERCENT_CPU
.tree_sort_key=PID .tree_sort_key=PID
.tree_view=0
.tree_view_always_by_pid=0 .tree_view_always_by_pid=0
.tree_view=0
.sort_direction=-1 .sort_direction=-1
.tree_sort_direction=1 .tree_sort_direction=1
.all_branches_collapsed=0 .all_branches_collapsed=0
screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command
.sort_key=IO_RATE .sort_key=IO_RATE
.tree_sort_key=PID .tree_sort_key=PID
.tree_view=0
.tree_view_always_by_pid=0 .tree_view_always_by_pid=0
.tree_view=0
.sort_direction=-1 .sort_direction=-1
.tree_sort_direction=1 .tree_sort_direction=1
.all_branches_collapsed=0 .all_branches_collapsed=0

View File

@ -140,13 +140,13 @@ font-1 = "waffle:size=10;3"
; modules-right = ipc clock ; modules-right = ipc clock
;modules-left = launcher sep workspaces sep cpu memory temperature filesystem ;modules-left = launcher sep workspaces sep cpu memory temperature filesystem
;modules-center = mpd sep date ;modules-center = mpd sep date China
;modules-right = color-switch sep mail sep network sep keyboard battery volume backlight sep sysmenu try ;modules-right = color-switch sep mail sep network sep keyboard battery volume backlight sep sysmenu try
#modules-right = color-switch sep network sep keyboard battery volume backlight sep sysmenu try #modules-right = color-switch sep network sep keyboard battery volume backlight sep sysmenu try
modules-left = launcher sep workspaces sep memory_bar cpu_bar sep temperature sep org-clock modules-left = launcher sep workspaces sep memory_bar cpu_bar sep temperature sep org-clock
modules-center = date sep mu4e_edu mu4e ssh keepassxc modules-center = prayers date sep mu4e_a mu4e_edu mu4e ssh keepassxc
modules-right = color-switch sep network sep keyboard sep volume brightness sep filesystem_bar sep battery sep sysmenu tray modules-right = color-switch sep network sep keyboard sep volume brightness sep filesystem_bar sep battery sep sysmenu
;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ ;; _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
; The separator will be inserted between the output of each module ; The separator will be inserted between the output of each module

View File

@ -17,6 +17,35 @@
;format-prefix =  ;format-prefix = 
;label-padding = 1 ;label-padding = 1
;format-prefix-foreground = ${color.yellow} ;format-prefix-foreground = ${color.yellow}
;
[module/prayers]
type = custom/script
exec = $HOME/bin/prayer-times status
interval = 60
;label = %{A:$HOME/bin/prayer-times yad:}%{F#83CAFA}󱠧 %{F-} %output%%{A}
label = %{A:$HOME/bin/prayer-times yad:}%{F#83CAFA} %{F-}%output%%{A}
[module/China]
type = custom/script
interval = 5
#exec = TZ=Asia/Shanghai date "+%H:%M %Z"
exec = echo "("$(TZ=Asia/Riyadh date "+%H:%M %Z")")"
content-foreground = ${color.blue}
[module/mu4e_a]
type = custom/script
# Educational emails
exec = find ~/.mail -path '*\\.com/*/new/*' -type f | wc -l
interval = 5
format = <label>
label-padding = 1
format-prefix =
format-prefix-foreground = ${color.green}
[module/mu4e_edu] [module/mu4e_edu]
type = custom/script type = custom/script
@ -35,7 +64,7 @@ format-prefix-foreground = ${color.yellow}
type = custom/script type = custom/script
# anything /but/ educational emails # anything /but/ educational emails
exec = find ~/.mail -path '*/*/new/*' -not -path '*\\.edu.*/*/new/*' -type f | wc -l exec = find ~/.mail -path '*/*/new/*' -not -path '*\\.edu.*/*/new/*' -not -path '*\\.com/*/new/*' -type f | wc -l
interval = 5 interval = 5

View File

@ -132,11 +132,11 @@ handle_image() {
# convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 # convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6
# exit 1;; # exit 1;;
## DjVu # DjVu
# image/vnd.djvu) image/vnd.djvu)
# ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \ ddjvu -format=tiff -quality=90 -page=1 -size="${DEFAULT_SIZE}" \
# - "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \ - "${IMAGE_CACHE_PATH}" < "${FILE_PATH}" \
# && exit 6 || exit 1;; && exit 6 || exit 1;;
## Image ## Image
image/*) image/*)