changeset 0:4785806e8a85

Initial import
author David Demelier <markand@malikania.fr>
date Thu, 18 Aug 2016 13:44:09 +0200
parents
children 02f6f8603d94
files README.md dmenu_mpc dmenu_mpc_add dmenu_shutdown dmenu_ssh
diffstat 5 files changed, 198 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Thu Aug 18 13:44:09 2016 +0200
@@ -0,0 +1,41 @@
+dmenu-scripts
+=====================================================================
+
+Some scripts using [dmenu][].
+
+Connect your window manager keybinds to these scripts. You can also use
+[xbindkeys][].
+
+dmenu_mpc
+=========
+
+This script offers some basic operations for [mpd][] such as:
+
+  - play, pause
+  - next, prev
+  - and clear
+
+Requires: [mpc][].
+
+dmenu_mpc_add
+=============
+
+This script let you add music to mpc by searching albums.
+
+dmenu_shutdown
+==============
+
+Stop, restard or put your system in sleep.
+
+This script requires sudo without password, at least for the operations used in
+the script.
+
+dmenu_ssh
+=========
+
+Read the `~/.ssh/config` file to prompt a host to connect to.
+
+[dmenu]: http://tools.suckless.org/dmenu
+[mpc]: https://www.musicpd.org/clients/mpc
+[mpd]: https://www.musicpd.org
+[xbindkeys]: http://www.nongnu.org/xbindkeys
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmenu_mpc	Thu Aug 18 13:44:09 2016 +0200
@@ -0,0 +1,33 @@
+#!/bin/sh
+#
+# dmenu_mpc -- basic mpc operations through dmenu
+#
+# Copyright (c) 2016 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if ! which dmenu > /dev/null 2>&1; then
+    echo "dmenu is missing" 1>&2;
+    exit 1;
+fi
+if ! which mpc > /dev/null 2>&1; then
+    echo "mpc is missing" 1>&2;
+    exit 1;
+fi
+
+cmd=$(echo -e "pause\nplay\nnext\nprev\nclear" | dmenu -p mpd )
+
+if [ -n "${cmd}" ]; then
+    mpc ${cmd} > /dev/null 2>&1
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmenu_mpc_add	Thu Aug 18 13:44:09 2016 +0200
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# dmenu_mpc_add -- convenient dmenu prompt for adding music to mpd
+#
+# Copyright (c) 2016 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if ! which dmenu > /dev/null 2>&1; then
+    echo "dmenu is missing" 1>&2;
+    exit 1;
+fi
+if ! which mpc > /dev/null 2>&1; then
+    echo "mpc is missing" 1>&2;
+    exit 1;
+fi
+
+lines=10
+album=$(mpc list album | dmenu -i -p "mpc add" -l $lines)
+
+if [ -z "$album" ]; then
+    exit 0;
+fi
+
+mpc search album "$album" | mpc add
+mpc play
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmenu_shutdown	Thu Aug 18 13:44:09 2016 +0200
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# dmenu_shutdown -- dmenu prompt for system shutdown
+#
+# Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if ! which dmenu > /dev/null 2>&1; then
+    echo "dmenu is missing" 1>&2;
+    exit 1;
+fi
+
+os=$(uname -s)
+cmd=$(echo -e "shutdown\nsuspend\nreboot" | dmenu -p "do")
+
+if [ "${cmd}" = "shutdown" ]; then
+    case "${os}" in
+    Linux)
+        sudo shutdown -h now
+        ;;
+    FreeBSD)
+        sudo shutdown -p now
+        ;;
+    esac
+elif [ "${cmd}" = "suspend" ]; then
+    case "${os}" in
+    Linux)
+        sudo pm-suspend
+        ;;
+    FreeBSD)
+        sudo acpiconf -s 3
+        ;;
+    esac
+elif [ "${cmd}" = "reboot" ]; then
+    sudo shutdown -r now
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dmenu_ssh	Thu Aug 18 13:44:09 2016 +0200
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# dmenu_ssh -- ssh prompt for dmenu
+#
+# Copyright (c) 2016 David Demelier <markand@malikania.fr>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+
+if ! which dmenu > /dev/null 2>&1; then
+    echo "missing dmenu" 1>&2;
+    exit 1
+fi
+if ! which ssh > /dev/null 2>&1; then
+    echo "missing ssh" 1>&2;
+    exit 1
+fi
+
+if [ ! -r "${HOME}/.ssh/config" ]; then
+    echo "missing ${HOME}/.ssh/config" 1>&2;
+    exit 1;
+fi
+
+term=${1:-xterm}
+host=$(grep -Ei "Host\s" ${HOME}/.ssh/config | awk '{ print $2 '} | dmenu -p ssh)
+
+if [ -n "${host}" ]; then
+    ${term} -e ssh ${host}
+fi