From 0b65deb252324d6e6d4dc3bd23a2689f4bdcb1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Tue, 30 Mar 2021 13:34:15 +0300 Subject: [PATCH] Calendar and status bar --- config/mpv/mpv.conf | 6 +-- local/bin/dmenu-edit | 4 +- local/bin/dmenu_surf | 2 - local/bin/pacontrol.sh | 12 ++--- local/bin/status-bar/date | 20 +++++++- local/bin/status-bar/todo | 6 +++ local/bin/status-bar/weather | 90 ++++++++++++++++++------------------ suckless/dwmblocks/config.h | 2 + suckless/st/config.h | 6 +-- 9 files changed, 84 insertions(+), 64 deletions(-) create mode 100755 local/bin/status-bar/todo diff --git a/config/mpv/mpv.conf b/config/mpv/mpv.conf index d067562f..8dc6237f 100644 --- a/config/mpv/mpv.conf +++ b/config/mpv/mpv.conf @@ -91,12 +91,12 @@ # Pretend to be a web browser. Might fix playback with some streaming sites, # but also will break with shoutcast streams. -#user-agent="Mozilla/5.0" +user-agent="Mozilla/5.0" # cache settings # # Use a large seekable RAM cache even for local input. -#cache=yes +cache=yes # # Use extra large RAM cache (needs cache=yes to make it useful). #demuxer-max-bytes=500M @@ -112,7 +112,7 @@ #cache-on-disk=yes # Display English subtitles if available. -#slang=en +slang=en # Play Finnish audio if available, fall back to English otherwise. #alang=fi,en diff --git a/local/bin/dmenu-edit b/local/bin/dmenu-edit index de0c6862..8ff97790 100755 --- a/local/bin/dmenu-edit +++ b/local/bin/dmenu-edit @@ -1,7 +1,7 @@ #!/bin/sh DMENU='dmenu -z 1900 -x 10 -y 10 -i' -blacklist="powerlevel10k|secret|gitignore|log|plugins|patch" +blacklist="powerlevel10k|secret|gitignore|log|plugins|patches|config/surf" whitelist="config.h|keybind.h|colors.h|color.h|rules.h" declare -A mappings @@ -9,7 +9,7 @@ items=$(find "$HOME/.dotfiles/config" -type f | grep -Ev $blacklist | sed -n "s| scripts=$(find "$HOME/.dotfiles/local/bin" -type f | grep -Ev $blacklist | sed -n "s|$HOME/.dotfiles/local/bin/|scripts/|p") suckless=$(find "$HOME/.dotfiles/suckless" -type f | grep -Ev $blacklist | grep -E $whitelist | sed -n "s|$HOME/.dotfiles/suckless/|suckless/|p") -selection=$(echo "$items\n$scripts\n$suckless" | $DMENU) +selection=$(echo -e "$items\n$scripts\n$suckless" | $DMENU) if [ ! "$selection" = "" ]; then if [ $(echo $selection | cut -d"/" -f 1) = "scripts" ]; then diff --git a/local/bin/dmenu_surf b/local/bin/dmenu_surf index 322380a8..d139d8c2 100755 --- a/local/bin/dmenu_surf +++ b/local/bin/dmenu_surf @@ -3,8 +3,6 @@ lines=12 blacklist='google' -# cat ~/.surf/history.txt | sed -E 's/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} *([^ ]*) *(.*)/\2 : \1/g' | sort | uniq -# selection=$(cat ~/.surf/history.txt | grep -Eiv $blacklist| sed -E 's/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} *([^ ]*) *(.*)/\2 : \1/g' | sort | uniq | dmenu -l $lines -i -p "Enter URL") selection=$(echo "" | dmenu -p "Enter URL") if [ ! -z "$selection" ] diff --git a/local/bin/pacontrol.sh b/local/bin/pacontrol.sh index 9be0a240..03aba72e 100755 --- a/local/bin/pacontrol.sh +++ b/local/bin/pacontrol.sh @@ -35,12 +35,8 @@ vol_interval=5 sinks=$(pactl list short sinks | cut -c 1) latest_sink=${sinks[*]: -1} -SINK=$(pactl list short sinks | grep -n RUNNING | cut -d":" -f1) -if [ "$SINK" = "" ]; then - SINK=1 -fi -NOW=$(pactl list sinks | grep '^[[:space:]]Volume:' | head -n $SINK | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' ) -MUTE=$(pactl list sinks | grep '^[[:space:]]Mute:'| head -n $SINK | tail -n 1 | awk -F ":" '{print $2}'| xargs) +NOW=$(pactl list sinks | grep '^[[:space:]]Volume:' | head -n $latest_sink | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' ) +MUTE=$(pactl list sinks | grep '^[[:space:]]Mute:'| head -n $latest_sink | tail -n 1 | awk -F ":" '{print $2}'| xargs) case $1 in "up") @@ -65,8 +61,8 @@ case $1 in ;; *) usage ;; esac -NOW=$(pactl list sinks | grep '^[[:space:]]Volume:' | head -n $SINK | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' ) -MUTE=$(pactl list sinks | grep '^[[:space:]]Mute:'| head -n $SINK | tail -n 1 | awk -F ":" '{print $2}'| xargs) +NOW=$(pactl list sinks | grep '^[[:space:]]Volume:' | head -n $latest_sink | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' ) +MUTE=$(pactl list sinks | grep '^[[:space:]]Mute:'| head -n $latest_sink | tail -n 1 | awk -F ":" '{print $2}'| xargs) kill -48 $(pidof dwmblocks) send_notification $NOW $MUTE diff --git a/local/bin/status-bar/date b/local/bin/status-bar/date index 6e1909ac..faae4400 100755 --- a/local/bin/status-bar/date +++ b/local/bin/status-bar/date @@ -10,10 +10,28 @@ fi cmd=$(date +"%h %e") -#echo "$ifg $icon $tfg$cmd" echo -n "^c#0f111a^^b#88c0d0^ $icon $events$cmd ^d^" case $BLOCK_BUTTON in 1) setsid -f st -c center -n center -e calcurse;; esac +next=$(calcurse -n | tail -1) + +if [ ! "$next" = "" ]; then + name=$(echo "$next" | cut -d ' ' -f 5- -) + time_left=$(date --date="$(echo "$next" | cut -d '[' -f2 | cut -d ']' -f1 )" "+%k%M") + + if [ "$time_left" -lt 30 ]; then + if [ ! -f "$XDG_CACHE_HOME/calcurse" ];then + touch "$XDG_CACHE_HOME/calcurse" + fi + + if [ "$(grep "$name" "$XDG_CACHE_HOME/calcurse")" = "" ]; then + time=$(calcurse -a | grep -E "\s*$name\$" -B 1 | head -n 1 | cut -c4-8) + echo "$name" > "$XDG_CACHE_HOME/calcurse" + canberra-gtk-play -i message + dunstify -a " Event approaching" "[$time] $name" + fi + fi +fi diff --git a/local/bin/status-bar/todo b/local/bin/status-bar/todo new file mode 100755 index 00000000..17ef587c --- /dev/null +++ b/local/bin/status-bar/todo @@ -0,0 +1,6 @@ +#!/bin/sh + +todos=$(calcurse -t | tail -n +2 | wc -l) + +echo -n "^c#81a1c1^ ^d^ $todos" + diff --git a/local/bin/status-bar/weather b/local/bin/status-bar/weather index ee5e5500..b7d53555 100755 --- a/local/bin/status-bar/weather +++ b/local/bin/status-bar/weather @@ -9,51 +9,51 @@ WCODES=( ["113"]="^c#ebcb8b^ " ["116"]="^c#ebcb8b^杖" ["119"]="^c#ffffff^摒" - ["122"]="^c#ffffff^ " - ["143"]="^c#ffffff^ " - ["176"]="^c#81a1c1^ " - ["179"]="^c#81a1c1^ " - ["182"]="^c#81a1c1^ " - ["185"]="^c#81a1c1^ " - ["200"]="^c#81a1c1^ " - ["227"]="^c#ffffff^ " - ["230"]="^c#ffffff^ " - ["248"]="^c#ffffff^ " - ["260"]="^c#ffffff^ " - ["263"]="^c#81a1c1^ " - ["266"]="^c#81a1c1^ " - ["281"]="^c#81a1c1^ " - ["284"]="^c#81a1c1^ " - ["293"]="^c#81a1c1^ " - ["296"]="^c#81a1c1^ " - ["299"]="^c#81a1c1^ " - ["302"]="^c#81a1c1^ " - ["305"]="^c#81a1c1^ " - ["308"]="^c#81a1c1^ " - ["311"]="^c#81a1c1^ " - ["314"]="^c#81a1c1^ " - ["317"]="^c#81a1c1^ " - ["320"]="^c#ffffff^ " - ["323"]="^c#81a1c1^ " - ["326"]="^c#81a1c1^ " - ["329"]="^c#ffffff^ " - ["332"]="^c#ffffff^ " - ["335"]="^c#81a1c1^ " - ["338"]="^c#ffffff^ " - ["350"]="^c#81a1c1^ " - ["353"]="^c#81a1c1^ " - ["356"]="^c#81a1c1^ " - ["359"]="^c#81a1c1^ " - ["362"]="^c#81a1c1^ " - ["365"]="^c#81a1c1^ " - ["368"]="^c#81a1c1^ " - ["371"]="^c#81a1c1^ " - ["374"]="^c#81a1c1^ " - ["377"]="^c#81a1c1^ " - ["386"]="^c#81a1c1^ " - ["389"]="^c#81a1c1^ " - ["392"]="^c#81a1c1^ " - ["395"]="^c#81a1c1^ " + ["122"]="^c#ffffff^ " + ["143"]="^c#ffffff^ " + ["176"]="^c#81a1c1^ " + ["179"]="^c#81a1c1^ " + ["182"]="^c#81a1c1^ " + ["185"]="^c#81a1c1^ " + ["200"]="^c#81a1c1^ " + ["227"]="^c#ffffff^ " + ["230"]="^c#ffffff^ " + ["248"]="^c#ffffff^ " + ["260"]="^c#ffffff^ " + ["263"]="^c#81a1c1^ " + ["266"]="^c#81a1c1^ " + ["281"]="^c#81a1c1^ " + ["284"]="^c#81a1c1^ " + ["293"]="^c#81a1c1^ " + ["296"]="^c#81a1c1^ " + ["299"]="^c#81a1c1^ " + ["302"]="^c#81a1c1^ " + ["305"]="^c#81a1c1^ " + ["308"]="^c#81a1c1^ " + ["311"]="^c#81a1c1^ " + ["314"]="^c#81a1c1^ " + ["317"]="^c#81a1c1^ " + ["320"]="^c#ffffff^ " + ["323"]="^c#81a1c1^ " + ["326"]="^c#81a1c1^ " + ["329"]="^c#ffffff^ " + ["332"]="^c#ffffff^ " + ["335"]="^c#81a1c1^ " + ["338"]="^c#ffffff^ " + ["350"]="^c#81a1c1^ " + ["353"]="^c#81a1c1^ " + ["356"]="^c#81a1c1^ " + ["359"]="^c#81a1c1^ " + ["362"]="^c#81a1c1^ " + ["365"]="^c#81a1c1^ " + ["368"]="^c#81a1c1^ " + ["371"]="^c#81a1c1^ " + ["374"]="^c#81a1c1^ " + ["377"]="^c#81a1c1^ " + ["386"]="^c#81a1c1^ " + ["389"]="^c#81a1c1^ " + ["392"]="^c#81a1c1^ " + ["395"]="^c#81a1c1^ " ) getforecast() { curl -sf "wttr.in/$LOCATION" > "$weatherreport" || exit 1 ;} diff --git a/suckless/dwmblocks/config.h b/suckless/dwmblocks/config.h index 00f1748f..0ecb1863 100644 --- a/suckless/dwmblocks/config.h +++ b/suckless/dwmblocks/config.h @@ -2,12 +2,14 @@ #define PATH(name) "/home/yigit/.local/share/bin/status-bar/"name static Block blocks[] = { +// { "", PATH("clipboard"), 120, 28}, { "", PATH("screensaver"), 120, 19}, { "", PATH("dunst"), 120, 18}, { "", PATH("mail"), 120, 23}, { "", PATH("keyboard"), 120, 24}, { "", PATH("bluetooth"), 120, 26}, { "", PATH("mconnect"), 120, 20}, + { "", PATH("todo"), 120, 27}, { "", PATH("nextcloud"), 600, 25}, { "", PATH("cpu-temp"), 30, 17}, { "", PATH("memory"), 120, 21}, diff --git a/suckless/st/config.h b/suckless/st/config.h index 95417f0f..9a61f2ed 100644 --- a/suckless/st/config.h +++ b/suckless/st/config.h @@ -190,9 +190,9 @@ static MouseShortcut mshortcuts[] = { #define TERMMOD (ControlMask|ShiftMask) #define ALTMOD (Mod1Mask|ShiftMask) -static char *openurlcmd[] = { "/bin/sh", "-c", "/home/yigit/.scripts/st-urlhandler -o", "externalpipe", NULL }; -static char *copyurlcmd[] = { "/bin/sh", "-c", "/home/yigit/.scripts/st-urlhandler -c", "externalpipe", NULL }; -static char *copyoutput[] = { "/bin/sh", "-c", "/home/yigit/.scripts/st-copyout", "externalpipe", NULL }; +static char *openurlcmd[] = { "/bin/sh", "-c", "/home/yigit/.local/share/bin/st-urlhandler -o", "externalpipe", NULL }; +static char *copyurlcmd[] = { "/bin/sh", "-c", "/home/yigit/.local/share/bin/st-urlhandler -c", "externalpipe", NULL }; +static char *copyoutput[] = { "/bin/sh", "-c", "/home/yigit/.local/share/bin/st-copyout", "externalpipe", NULL }; static unsigned int cursorstyle = 1; static Rune stcursor = 0x2603; /* snowman (U+2603) */