t* dwm + patches URI git clone git://git.codevoid.de/dwm-sdk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit d7c8e26f1a28ab5d707baf7947499c587f79d111 DIR parent f9863c9844ae49da49b61899e66f942ef5344215 URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Wed, 23 May 2018 20:15:34 +0200 Volume control + scripts Diffstat: M config.h | 14 +++++++++----- A scripts/browser | 45 +++++++++++++++++++++++++++++++ A scripts/mixer | 2 ++ A scripts/pass | 26 ++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 5 deletions(-) --- DIR diff --git a/config.h b/config.h t@@ -59,13 +59,15 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; -static const char *bigtermcmd[] = { "st", "-f FuraCode Nerd Font:size=20:antialias=false:autohint=false", NULL }; -static const char *browsercmd[] = { ".dwm/browser", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *passmenucmd[] = { ".dwm/passmenu", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *termcmd[] = { "st", NULL }; +static const char *bigtermcmd[] = { "st", "-f FuraCode Nerd Font:size=20:antialias=false:autohint=false", NULL }; static const char scratchpadname[] = "scratchpad"; static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; +static const char *browsercmd[] = { ".dwm/browser", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *passmenucmd[] = { ".dwm/passmenu", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *volumeupcmd[] = { ".dwm/mixer", "+2", NULL }; +static const char *volumedowncmd[] = { ".dwm/mixer", "-2", NULL }; static Key keys[] = { /* modifier key function argument */ t@@ -76,6 +78,8 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_f, spawn, {.v = browsercmd } }, { MODKEY|ShiftMask, XK_p, spawn, {.v = passmenucmd } }, { MODKEY, XK_minus, togglescratch, {.v = scratchpadcmd } }, + { 0, 0x1008ff13,spawn, {.v = volumeupcmd } }, + { 0, 0x1008ff11,spawn, {.v = volumedowncmd } }, // ui modifier { MODKEY, XK_b, togglebar, {0} }, DIR diff --git a/scripts/browser b/scripts/browser t@@ -0,0 +1,45 @@ +#!/bin/sh +BROWSER_OPEN="surf" + +echo "Launching dmenu" +BM=$(cat ~/.browser-bookmarks | dmenu -p "Browser:" "$@") + +echo "Check if search string contains dot" +if echo "$BM" | grep -q '\.'; then + echo "Check if dot string is in bookmarks" + if ! grep -q "$BM" ~/.browser-bookmarks; then + echo "Add dot string to bookmarks" + echo "$BM" >> ~/.browser-bookmarks + fi + echo "Open dot string in browser" + $BROWSER_OPEN "$BM" + exit 0 +fi + +echo "Check for clipboard url" +if [ "$BM" = "paste_from_clipboard" ]; then + echo "Open clipboard as URL" + $BROWSER_OPEN "$(xclip -o -selection clipboard | sed 's/ /+/g')" + exit 0 +fi + +echo "Check for clipboard search" +if [ "$BM" = "search_from_clipboard" ]; then + echo "Open clipboard as search" + $BROWSER_OPEN "https://duckduckgo.com/?q=$(xclip -o -selection clipboard | sed 's/ /+/g')" + exit 0 +fi + +echo "Check for clipboard image search" +if [ "$BM" = "search_image_from_clipboard" ]; then + echo "Open clipboard as search" + $BROWSER_OPEN "https://duckduckgo.com/?ia=images&iax=images&q=$(xclip -o -selection clipboard | sed 's/ /+/g')" + exit 0 +fi + +echo "No dot, no clipboard command... search for it!" +if [ "$BM" != "" ]; then + $BROWSER_OPEN "https://duckduckgo.com/?q=$(echo $BM | sed 's/ /+/g')" + exit 0 +fi + DIR diff --git a/scripts/mixer b/scripts/mixer t@@ -0,0 +1,2 @@ +#!/bin/sh +mixer vol $1 && killall -SIGUSR1 dwmstatus DIR diff --git a/scripts/pass b/scripts/pass t@@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | dmenu -i "$@") + +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2> /dev/null + notify-send -t 16000 -a "Password Store" $(pass "$password" | head -2 | tail -1) +else + pass show "$password" | { read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - +fi