From a81a9a3f2a2c1af14f1f0b7440a4b85ae3011c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yi=C4=9Fit=20=C3=87olako=C4=9Flu?= Date: Thu, 25 Mar 2021 12:16:11 +0300 Subject: [PATCH] Added wallabag dmenu script --- misc/calcurse/conf | 32 ++++++++++++++ misc/calcurse/keys | 94 +++++++++++++++++++++--------------------- misc/profile | 2 +- scripts/dmenu-wallabag | 52 +++++++++++++++++++++++ suckless/dmenu/dmenu.c | 8 ++-- suckless/dwm/keybind.h | 5 +++ 6 files changed, 141 insertions(+), 52 deletions(-) create mode 100755 scripts/dmenu-wallabag diff --git a/misc/calcurse/conf b/misc/calcurse/conf index e69de29b..1ce2ab07 100644 --- a/misc/calcurse/conf +++ b/misc/calcurse/conf @@ -0,0 +1,32 @@ +appearance.calendarview=monthly +appearance.compactpanels=no +appearance.defaultpanel=calendar +appearance.layout=1 +appearance.headerline=yes +appearance.eventseparator=yes +appearance.dayseparator=yes +appearance.emptyline=yes +appearance.emptyday=-- +appearance.notifybar=yes +appearance.sidebarwidth=0 +appearance.theme=red on default +appearance.todoview=hide-completed +appearance.headingpos=right-justified +daemon.enable=no +daemon.log=no +format.inputdate=1 +format.notifydate=%a %F +format.notifytime=%T +format.outputdate=%D +format.dayheading=%B %e, %Y +general.autogc=no +general.autosave=yes +general.confirmdelete=yes +general.confirmquit=yes +general.firstdayofweek=monday +general.multipledays=yes +general.periodicsave=0 +general.systemevents=yes +notification.command=printf '\a' +notification.notifyall=flagged-only +notification.warning=300 diff --git a/misc/calcurse/keys b/misc/calcurse/keys index 28ff9e43..0f5ee8da 100644 --- a/misc/calcurse/keys +++ b/misc/calcurse/keys @@ -6,50 +6,50 @@ # via the key configuration menu of the interactive user # interface. It should not be edited directly. -generic-cancel ESC -generic-select SPC -generic-credits @ -generic-help ? -generic-quit q Q -generic-save s S ^S -generic-reload R -generic-copy c -generic-paste p ^V -generic-change-view TAB -generic-import i I -generic-export x X -generic-goto g G -generic-other-cmd o O -generic-config-menu C -generic-redraw ^R -generic-add-appt ^A -generic-add-todo ^T -generic-prev-day T ^H -generic-next-day t ^L -generic-prev-week W ^K -generic-next-week w -generic-prev-month M -generic-next-month m -generic-prev-year Y -generic-next-year y -generic-scroll-down ^N -generic-scroll-up ^P -generic-goto-today ^G -generic-command : -move-right l L RGT -move-left h H LFT -move-down j J DWN -move-up k K UP -start-of-week 0 -end-of-week $ -add-item a A -del-item d D -edit-item e E -view-item v V RET -pipe-item | -flag-item ! -repeat r -edit-note n N -view-note > -raise-priority + -lower-priority - +generic-cancel ESC +generic-select SPC +generic-credits @ +generic-help ? +generic-quit q Q +generic-save s S ^S +generic-reload R +generic-copy c +generic-paste p ^V +generic-change-view TAB +generic-import i I +generic-export x X +generic-goto g G +generic-other-cmd o O +generic-config-menu C +generic-redraw ^R +generic-add-appt ^A +generic-add-todo ^T +generic-prev-day T ^H +generic-next-day t ^L +generic-prev-week W ^K +generic-next-week w +generic-prev-month M +generic-next-month m +generic-prev-year Y +generic-next-year y +generic-scroll-down ^N +generic-scroll-up ^P +generic-goto-today ^G +generic-command : +move-right l L RGT +move-left h H LFT +move-down j J DWN +move-up k K UP +start-of-week 0 +end-of-week $ +add-item a A +del-item d D +edit-item e E +view-item v V RET +pipe-item | +flag-item ! +repeat r +edit-note n N +view-note > +raise-priority + +lower-priority - diff --git a/misc/profile b/misc/profile index 1c538555..ab244a02 100755 --- a/misc/profile +++ b/misc/profile @@ -9,7 +9,7 @@ export ANDROID_HOME=~/Android/Sdk export FLUTTER_HOME=~/flutter export TMUX_PLUGIN_MANAGER_PATH=~/.tmux/plugins export BORG_KEYS_DIR=~/.keys/borg -export BROWSER=firefox-developer-edition +export BROWSER="/home/yigit/.scripts/brave-start" export EDITOR=vim export GOPATH=$HOME/go export ANDROID_HOME=/home/yigit/Android diff --git a/scripts/dmenu-wallabag b/scripts/dmenu-wallabag new file mode 100755 index 00000000..f57fb4d9 --- /dev/null +++ b/scripts/dmenu-wallabag @@ -0,0 +1,52 @@ +#!/bin/bash + + +itemcache="${XDG_DATA_HOME:-$HOME/.cache}/wallabag-dmenu" + +DMENU=${DMENU:-dmenu} + +usage() { + cat <<-EOF + usage: dmenu-wallabag [-lah] + -l List Entries + -a Add an entry + -h Print help + EOF + +} + +update_items(){ + [ "$(date -r "$itemcache" "+%d-%m-%Y")" = "$(date '+%d-%m-%Y')" ] || + wallabag list | head -n -1 | tail -n +2 > $itemcache +} + +list_entries() { + update_items + items="$(cat $itemcache)" + selection=$(echo -e "$items\n~SYNC~" | dmenu -l 10 -p "Choose an article:") + if [ "$selection" = "~SYNC~" ]; then + wallabag list | head -n -1 | tail -n +2 > $itemcache + items="$(cat $itemcache)" + selection=$(echo "$items" | dmenu -l 10 -p "Choose an article:") + fi + selection=$(echo "$selection" | cut -d" " -f1) + wallabag update --read $selection + wallabag open $selection + wallabag list | head -n -1 | tail -n +2 > $itemcache +} + +add_entry() { + url=$(echo -n "" | dmenu -p "Enter URL:") + wallabag add $url + wallabag list | head -n -1 | tail -n +2 > $itemcache +} + +while getopts ':lah' opt; do + case "$opt" in + l) list_entries ;; + a) add_entry ;; + h) usage && exit;; + /?) echo "Unrecognized command: $OPTARG";; + esac +done + diff --git a/suckless/dmenu/dmenu.c b/suckless/dmenu/dmenu.c index 01b32ab0..7318551e 100644 --- a/suckless/dmenu/dmenu.c +++ b/suckless/dmenu/dmenu.c @@ -551,10 +551,10 @@ keypress(XKeyEvent *ev) case XK_bracketleft: cleanup(); exit(1); - case XK_h: ksym = XK_Up; break; - case XK_j: ksym = XK_Next; break; - case XK_k: ksym = XK_Prior; break; - case XK_l: ksym = XK_Down; break; + case XK_h: ksym = XK_Prior; break; + case XK_j: ksym = XK_Down; break; + case XK_k: ksym = XK_Up; break; + case XK_l: ksym = XK_Next; break; default: return; } diff --git a/suckless/dwm/keybind.h b/suckless/dwm/keybind.h index c845c7c9..4a6db65a 100644 --- a/suckless/dwm/keybind.h +++ b/suckless/dwm/keybind.h @@ -48,6 +48,9 @@ static const char *online_class[] = {"/home/yigit/.scripts/tedportal",NULL}; static const char *bwmenu[] = {"/home/yigit/.scripts/password_manager", NULL}; +static const char *wallabag_read[] = {"/home/yigit/.scripts/dmenu-wallabag", "-l",NULL}; +static const char *wallabag_add[] = {"/home/yigit/.scripts/dmenu-wallabag", "-a", NULL}; + static const char *network_manager[] = {"/home/yigit/.scripts/networkmanager_dmenu", NULL}; static const char *killall[] = {"/home/yigit/.scripts/dmenu-killall", NULL}; static const char *mconnect[] = {"/home/yigit/.scripts/dmenu-mconnect"}; @@ -135,6 +138,8 @@ static Key keys[] = { { MODKEY, XK_Print, spawn, {.v = windowshot } }, { MODKEY|ShiftMask, XK_e, spawn, {.v = simcrop } }, { MODKEY, XK_u, spawn, {.v = url} }, + { MODKEY, XK_w, spawn, {.v = wallabag_read} }, + { MODKEY|ShiftMask, XK_w, spawn, {.v = wallabag_add} }, { MODKEY, XK_g, spawn, {.v = google} }, { MODKEY|ShiftMask, XK_c, spawn, {.v = online_class} }, { MODKEY|ShiftMask, XK_m, spawn, {.v = mconnect} },