commit 81809cbe77633ed50ad879db95482c493f6e3f9c
parent 5588b79d4e7e97b8112adaff5962c02434dfa030
Author: Ed van Bruggen <edvb54@gmail.com>
Date: Mon, 13 Mar 2017 13:39:39 -0700
Rename scripts
Diffstat:
browse | | | 26 | ++++++++++++++++++++++++++ |
browse.sh | | | 26 | -------------------------- |
calc | | | 14 | ++++++++++++++ |
calc.sh | | | 14 | -------------- |
dwm-mode.sh | | | 34 | ---------------------------------- |
dwm_mode | | | 34 | ++++++++++++++++++++++++++++++++++ |
man | | | 6 | ++++++ |
man.sh | | | 6 | ------ |
menu | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
menu.sh | | | 41 | ----------------------------------------- |
prog | | | 3 | +++ |
prog.sh | | | 3 | --- |
todo | | | 27 | +++++++++++++++++++++++++++ |
todo.sh | | | 27 | --------------------------- |
win | | | 5 | +++++ |
win.sh | | | 5 | ----- |
16 files changed, 156 insertions(+), 156 deletions(-)
diff --git a/browse b/browse
@@ -0,0 +1,26 @@
+#!/bin/sh
+# TODO: multisel
+
+target="$2"
+[ -z "$target" ] && target="$(realpath .)"
+
+while true; do
+ sel="$(ls -1a "$target" | grep -v '^\.$' | dmenu -i -p "$target" -l 25 $@)"
+ ec=$?
+ [ "$ec" -ne 0 ] && exit $ec
+
+ c="$(echo "$sel" |cut -b1)"
+ if [ "$c" = "/" ]; then
+ newt="$sel"
+ else
+ newt="$(realpath "${target}/${sel}")"
+ fi
+
+ if [ -e "$newt" ]; then
+ target="$newt"
+ if [ ! -d "$target" ]; then
+ echo "$target"
+ exit 0
+ fi
+ fi
+done
diff --git a/browse.sh b/browse.sh
@@ -1,26 +0,0 @@
-#!/bin/sh
-# TODO: multisel
-
-target="$2"
-[ -z "$target" ] && target="$(realpath .)"
-
-while true; do
- sel="$(ls -1a "$target" | grep -v '^\.$' | dmenu -i -p "$target" -l 25 $@)"
- ec=$?
- [ "$ec" -ne 0 ] && exit $ec
-
- c="$(echo "$sel" |cut -b1)"
- if [ "$c" = "/" ]; then
- newt="$sel"
- else
- newt="$(realpath "${target}/${sel}")"
- fi
-
- if [ -e "$newt" ]; then
- target="$newt"
- if [ ! -d "$target" ]; then
- echo "$target"
- exit 0
- fi
- fi
-done
diff --git a/calc b/calc
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+# Calculator using dmenu as an interface
+
+dmenucmd="dmenu -p Calc $@"
+
+# run dmenu calculator while the result is not empty
+while : ; do
+ # use contents of clipboard as option, pass into bc to be calculated
+ result=$(xsel -o -b | $dmenucmd | xargs echo | bc 2>&1)
+ if [[ $result ]]; then # if result is empty (the last one), don't copy it to clipboard
+ printf "$result" | xsel -b
+ fi
+ [[ $result ]] || break # if result is empty, break from while loop
+done
diff --git a/calc.sh b/calc.sh
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-# Calculator using dmenu as an interface
-
-dmenucmd="dmenu -p Calc $@"
-
-# run dmenu calculator while the result is not empty
-while : ; do
- # use contents of clipboard as option, pass into bc to be calculated
- result=$(xsel -o -b | $dmenucmd | xargs echo | bc 2>&1)
- if [[ $result ]]; then # if result is empty (the last one), don't copy it to clipboard
- printf "$result" | xsel -b
- fi
- [[ $result ]] || break # if result is empty, break from while loop
-done
diff --git a/dwm-mode.sh b/dwm-mode.sh
@@ -1,34 +0,0 @@
-#!/usr/bin/env bash
-# Change dwm window mode with dmenu
-
-# note that you have to manualy add and change the menu for your dwm config
-
-menu_list="tile\nfloating\nhtile\ndeck\ncentered\nspiral\ndwindle\ngaplessgrid\nhorizgrid\ntcl\nmonocle\n"
-dmenucmd="dmenu $@ -l 11"
-cmd=$(echo -ne "$menu_list" | eval "$dmenucmd")
-
-case $cmd in
- tile)
- xdotool key ctrl+super+t ;;
- floating)
- xdotool key ctrl+super+f ;;
- htile)
- xdotool key ctrl+super+h ;;
- deck)
- xdotool key ctrl+super+d ;;
- centered)
- xdotool key ctrl+super+c ;;
- spiral)
- xdotool key ctrl+super+s ;;
- dwindle)
- xdotool key ctrl+super+shift+s ;;
- gaplessgrid)
- xdotool key ctrl+super+g ;;
- horizgrid)
- xdotool key ctrl+super+shift+g ;;
- tcl)
- xdotool key ctrl+super+r ;;
- monocle)
- xdotool key ctrl+super+m ;;
-esac
-
diff --git a/dwm_mode b/dwm_mode
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# Change dwm window mode with dmenu
+
+# note that you have to manualy add and change the menu for your dwm config
+
+menu_list="tile\nfloating\nhtile\ndeck\ncentered\nspiral\ndwindle\ngaplessgrid\nhorizgrid\ntcl\nmonocle\n"
+dmenucmd="dmenu $@ -l 11"
+cmd=$(echo -ne "$menu_list" | eval "$dmenucmd")
+
+case $cmd in
+ tile)
+ xdotool key ctrl+super+t ;;
+ floating)
+ xdotool key ctrl+super+f ;;
+ htile)
+ xdotool key ctrl+super+h ;;
+ deck)
+ xdotool key ctrl+super+d ;;
+ centered)
+ xdotool key ctrl+super+c ;;
+ spiral)
+ xdotool key ctrl+super+s ;;
+ dwindle)
+ xdotool key ctrl+super+shift+s ;;
+ gaplessgrid)
+ xdotool key ctrl+super+g ;;
+ horizgrid)
+ xdotool key ctrl+super+shift+g ;;
+ tcl)
+ xdotool key ctrl+super+r ;;
+ monocle)
+ xdotool key ctrl+super+m ;;
+esac
+
diff --git a/man b/man
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+dmenucmd=$(man -k . | cut -d ' ' -f 1,2 | dmenu $@)
+[[ -z $dmenucmd ]] && exit
+dmenucmd=$(echo $dmenucmd | tr -d '()' | awk '{print $2, " ", $1}')
+echo $dmenucmd
diff --git a/man.sh b/man.sh
@@ -1,6 +0,0 @@
-#!/usr/bin/env bash
-
-dmenucmd=$(man -k . | cut -d ' ' -f 1,2 | dmenu $@)
-[[ -z $dmenucmd ]] && exit
-dmenucmd=$(echo $dmenucmd | tr -d '()' | awk '{print $2, " ", $1}')
-echo $dmenucmd
diff --git a/menu b/menu
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+draw_line () {
+ for i in {1..10}; do
+ printf "―"
+ done
+}
+
+menu_list=" run\n term\n web\n file\n edit\n view\n todo\n calc\n man\n htop\n$(draw_line)\n exit\n"
+dmenucmd="dmenu -c -i -l 12"
+cmd=$(echo -e "$menu_list" | eval "$dmenucmd")
+
+case $cmd in
+ *run)
+ dmenu_prog -c -l 20 ;;
+ *term)
+ tabbed -c st -w ;;
+ *web)
+ firefox > /dev/null 2>&1 ;;
+ *file)
+ thunar > /dev/null 2>&1 ;;
+ *edit) # TODO dont open if dmenu returned empty
+ st -e vim -p "$(dmenu_browse -c)" ;;
+ *view)
+ sxiv "$(dmenu_browse -c)" ;;
+ *todo)
+ dmenu_todo -c ;;
+ *calc)
+ dmenu_calc -c -l 1;;
+ *man)
+ st -e man $(dmenu_man -c -l 20) ;;
+ *htop)
+ st -g 68x6 -e htop ;;
+ *exit)
+ # dmenu_quit -c ;;
+ cbpp-exit ;;
+ *)
+ $cmd
+esac
+
+exit 0
diff --git a/menu.sh b/menu.sh
@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-
-draw_line () {
- for i in {1..10}; do
- printf "―"
- done
-}
-
-menu_list=" run\n term\n web\n file\n edit\n view\n todo\n calc\n man\n htop\n$(draw_line)\n exit\n"
-dmenucmd="dmenu -c -i -l 12"
-cmd=$(echo -e "$menu_list" | eval "$dmenucmd")
-
-case $cmd in
- *run)
- "$HOME"/.config/dmenu/prog.sh -c -l 20 ;;
- *term)
- tabbed -c st -w ;;
- *web)
- firefox > /dev/null 2>&1 ;;
- *file)
- thunar > /dev/null 2>&1 ;;
- *edit) # TODO dont open if dmenu returned empty
- st -e vim -p "$("$HOME"/.config/dmenu/browse.sh -c)" ;;
- *view) # TODO replace with browse.sh and feh
- geeqie "$HOME"/pictures/ ;;
- *todo)
- "$HOME"/.config/dmenu/todo.sh -c ;;
- *calc)
- "$HOME"/.config/dmenu/calc.sh -c -l 1;;
- *man)
- st -e man $("$HOME"/.config/dmenu/man.sh -c -l 20) ;;
- *htop)
- st -g 68x6 -e htop ;;
- *exit)
- # "$HOME"/.config/dmenu/quit.sh -c ;;
- cbpp-exit ;;
- *)
- $cmd
-esac
-
-exit 0
diff --git a/prog b/prog
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+dmenu_path | dmenu $@ | ${SHELL:-"/bin/sh"}
diff --git a/prog.sh b/prog.sh
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-dmenu_path | dmenu $@ | ${SHELL:-"/bin/sh"}
diff --git a/todo b/todo
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# TODO: | sort -s -k 1,1
+
+file=~/.todo
+height=$(cat $file | wc -l)
+prompt="Add/delete a task"
+
+if [ "$height" -gt 20 ]; then height=20; fi
+
+cmd=$(cat "$file" | dmenu $@ -l "$height" -p "$prompt:" )
+
+while [ -n "$cmd" ]; do
+ grep -q "^$cmd" $file
+ if [ $? = 0 ]; then
+ grep -v "^$cmd" $file > /tmp/todo
+ mv /tmp/todo $file
+ height=$((height-1))
+ else
+ echo "$cmd" >> $file
+ height=$((height+1))
+ fi
+ if [ "$height" -gt 20 ]; then height=20; fi
+ cmd=$(cat $file | dmenu $@ -l "$height" -p "$prompt:" )
+done
+
+exit 0
diff --git a/todo.sh b/todo.sh
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-# TODO: | sort -s -k 1,1
-
-file=~/.todo
-height=$(cat $file | wc -l)
-prompt="Add/delete a task"
-
-if [ "$height" -gt 20 ]; then height=20; fi
-
-cmd=$(cat "$file" | dmenu $@ -l "$height" -p "$prompt:" )
-
-while [ -n "$cmd" ]; do
- grep -q "^$cmd" $file
- if [ $? = 0 ]; then
- grep -v "^$cmd" $file > /tmp/todo
- mv /tmp/todo $file
- height=$((height-1))
- else
- echo "$cmd" >> $file
- height=$((height+1))
- fi
- if [ "$height" -gt 20 ]; then height=20; fi
- cmd=$(cat $file | dmenu $@ -l "$height" -p "$prompt:" )
-done
-
-exit 0
diff --git a/win b/win
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+# Use dmenu to focus on an open window
+
+win="$(lsw | dmenu -i -l 10 "$@" | cut -d ' ' -f 1)"
+[ "$win" ] && wmctrl -ia "$win" &
diff --git a/win.sh b/win.sh
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-# Use dmenu to focus on an open window
-
-win="$(lsw | dmenu -i -l 10 "$@" | cut -d ' ' -f 1)"
-[ "$win" ] && wmctrl -ia "$win" &