From c87dd5f7f3a946fbf58e3a0ebe36e7681ced1595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Thu, 25 Mar 2021 21:49:02 +0300 Subject: [PATCH] Scripts --- scripts/dunst_toggle.sh | 18 +++++++++++++++--- scripts/screensaver_toggle | 14 +++++++++++++- scripts/status-bar/screensaver | 4 ++-- suckless/dwm/keybind.h | 12 ++++-------- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/scripts/dunst_toggle.sh b/scripts/dunst_toggle.sh index f0bbc8b3..bd648443 100755 --- a/scripts/dunst_toggle.sh +++ b/scripts/dunst_toggle.sh @@ -1,26 +1,38 @@ #!/bin/zsh getargs() { - while getopts "se" opt + while getopts "set" opt do case $opt in s) start="true";; e) end="true";; + t) toggle="true";; esac done } start_dnd() { echo "off" > ~/.cache/dunst - dunstctl set-paused false + dunstctl set-paused true } + end_dnd() { echo "on" > ~/.cache/dunst - dunstctl set-paused true + dunstctl set-paused false notify-send "Do Not Disturb" "Do Not Disturb mode ended. Notifications will be shown."; } + +toggle_dnd() { + if [ $(cat ~/.cache/dunst) = "on" ]; then + start_dnd + else + end_dnd + fi +} + main() { getargs "$@"; [[ "$start" ]] && start_dnd; [[ "$end" ]] && end_dnd; + [[ "$toggle" ]] && toggle_dnd; kill -52 $(pidof dwmblocks) } main "$@" diff --git a/scripts/screensaver_toggle b/scripts/screensaver_toggle index 3f5ccf4f..38925774 100755 --- a/scripts/screensaver_toggle +++ b/scripts/screensaver_toggle @@ -1,10 +1,11 @@ #!/bin/zsh getargs() { - while getopts "se" opt + while getopts "set" opt do case $opt in s) start="true";; e) end="true";; + t) toggle="true";; esac done } @@ -18,10 +19,21 @@ end_dnd() { echo "on" > ~/.cache/screensaver notify-send "Screensaver on."; } + +toggle_dnd() { + if [ $(cat ~/.cache/screensaver) = "on" ]; then + start_dnd + else + end_dnd + fi +} + main() { getargs "$@"; [[ "$start" ]] && start_dnd; [[ "$end" ]] && end_dnd; + [[ "$toggle" ]] && toggle_dnd; kill -53 $(pidof dwmblocks) } + main "$@" diff --git a/scripts/status-bar/screensaver b/scripts/status-bar/screensaver index 226d82fa..c3009c2e 100755 --- a/scripts/status-bar/screensaver +++ b/scripts/status-bar/screensaver @@ -3,7 +3,7 @@ stats=$(<~/.cache/screensaver) if [ "$stats" = "off" ]; then - echo "^c#a48ead^ ^d^" + echo "^c#a48ead^零 ^d^" else - echo "^c#a48ead^ ^d^" + echo "^c#a48ead^鈴 ^d^" fi diff --git a/suckless/dwm/keybind.h b/suckless/dwm/keybind.h index 4a6db65a..6b135857 100644 --- a/suckless/dwm/keybind.h +++ b/suckless/dwm/keybind.h @@ -35,13 +35,11 @@ static const char *screenshot[] = { "scrot", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e", static const char *windowshot[] = { "scrot", "-u", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send \"SNAP\" \"$f\"", NULL }; static const char *simcrop[] = {"simcrop","-fc","-sc", "-g", "900x500",NULL}; -static const char *notification_off[] = {"/home/yigit/.scripts/dunst_toggle.sh","-s",NULL}; -static const char *notification_on[] = {"/home/yigit/.scripts/dunst_toggle.sh", "-e",NULL}; +static const char *notification[] = {"/home/yigit/.scripts/dunst_toggle.sh", "-t",NULL}; static const char *screen_off[] = {"xset", "dpms", "force", "off", NULL}; -static const char *screensaver_off[] = {"/home/yigit/.scripts/screensaver_toggle","-s",NULL}; -static const char *screensaver_on[] = {"/home/yigit/.scripts/screensaver_toggle", "-e",NULL}; +static const char *screensaver[] = {"/home/yigit/.scripts/screensaver_toggle", "-t",NULL}; static const char *online_class[] = {"/home/yigit/.scripts/tedportal",NULL}; @@ -73,11 +71,9 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_Return, spawn, {.v = tmuxcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, - { MODKEY, XK_i, spawn, {.v = screensaver_off} }, - { MODKEY|ShiftMask, XK_i, spawn, {.v = screensaver_on } }, + { MODKEY|ShiftMask, XK_i, spawn, {.v = screensaver} }, { MODKEY|ShiftMask, XK_o, spawn, {.v = screen_off } }, - { MODKEY, XK_n, spawn, {.v = notification_off} }, - { MODKEY|ShiftMask, XK_n, spawn, {.v = notification_on } }, + { MODKEY|ShiftMask, XK_n, spawn, {.v = notification } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} },