mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 19:40:24 +10:00
Pushing dmenu and related scripts.
This commit is contained in:
18
.dmenu/dbdb.sh
Executable file
18
.dmenu/dbdb.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# dmenu-based directory browser
|
||||||
|
# to run from terminal:
|
||||||
|
# source /path/to/dbdb.sh
|
||||||
|
# or bind it to shortcut:
|
||||||
|
# echo bind \'\"\\C-o\":\"source /path/to/dbdb.sh\\n\"\' >> ~/.bashrc
|
||||||
|
|
||||||
|
chosen="placeholder"
|
||||||
|
|
||||||
|
while [ ! -z "$chosen" ]; do
|
||||||
|
DIRs=$( ls -a1p | grep -P '^\w[^\$/]+/$' | awk -vRS="\n" -vORS="\t" '1')
|
||||||
|
DOTDs=$( ls -a1p | grep -P '^\.[^\$/]+/$' | awk -vRS="\n" -vORS="\t" '1')
|
||||||
|
FILEs=$( ls -a1p | grep -P '^\w[^\$/]+$' | awk -vRS="\n" -vORS=" \t" '1')
|
||||||
|
DOTFs=$( ls -a1p | grep -P '^\.[^\$/]+$' | awk -vRS="\n" -vORS=" \t" '1')
|
||||||
|
clear && printf "\e[1;7;33m $(pwd) \e[0m\n$FILEs\n\e[0;38;5;238m$DOTFs\e[0m\n"
|
||||||
|
chosen=`( ( echo -e "$DIRs$DOTDs" | awk -vRS="\t" -vORS="\n" '1' ) | dmenu -i )`
|
||||||
|
cd "$chosen"
|
||||||
|
done
|
||||||
29
.dmenu/dbrowse
Executable file
29
.dmenu/dbrowse
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# TODO: multisel
|
||||||
|
|
||||||
|
target="$1"
|
||||||
|
[ -z "$target" ] && target="$(realpath .)"
|
||||||
|
prompt="$2"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
p="$prompt"
|
||||||
|
[ -z "$p" ] && p="$target"
|
||||||
|
sel="$(ls -1a "$target" |grep -v '^\.$' | dmenu -p "$p" -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
|
||||||
20
.dmenu/dmenu_edit_dwm
Executable file
20
.dmenu/dmenu_edit_dwm
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ____ _____
|
||||||
|
# | _ \_ _| Derek Taylor (DistroTube)
|
||||||
|
# | | | || | http://www.youtube.com/c/DistroTube
|
||||||
|
# | |_| || | http://www.gitlab.com/dwt1/
|
||||||
|
# |____/ |_|
|
||||||
|
#
|
||||||
|
# Use dmenu to open and edit a file from a given list.
|
||||||
|
# I use this to quickly open my dwm source files in vim.
|
||||||
|
|
||||||
|
# Global variables:
|
||||||
|
FILES=${1:-"/home/dt/dwm"}
|
||||||
|
DMENU='dmenu -l -i'
|
||||||
|
EDITOR='st -e vim'
|
||||||
|
# Show list of options
|
||||||
|
choice=$(ls -a "${FILES}" | $DMENU -p "« dwm » source code:")
|
||||||
|
|
||||||
|
if [ $choice ]; then
|
||||||
|
$EDITOR ${FILES}/${choice}
|
||||||
|
fi
|
||||||
20
.dmenu/dmenu_edit_st
Executable file
20
.dmenu/dmenu_edit_st
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ____ _____
|
||||||
|
# | _ \_ _| Derek Taylor (DistroTube)
|
||||||
|
# | | | || | http://www.youtube.com/c/DistroTube
|
||||||
|
# | |_| || | http://www.gitlab.com/dwt1/
|
||||||
|
# |____/ |_|
|
||||||
|
#
|
||||||
|
# Use dmenu to open and edit a file from a given list.
|
||||||
|
# I use this to quickly open my st source files in vim.
|
||||||
|
|
||||||
|
# Global variables:
|
||||||
|
FILES=${1:-"/home/dt/st"}
|
||||||
|
DMENU='dmenu -l -i'
|
||||||
|
EDITOR='st -e vim'
|
||||||
|
# Show list of options
|
||||||
|
choice=$(ls -a "${FILES}" | $DMENU -p "« st » source code:")
|
||||||
|
|
||||||
|
if [ $choice ]; then
|
||||||
|
$EDITOR ${FILES}/${choice}
|
||||||
|
fi
|
||||||
31
.dmenu/dmenu_running_apps
Executable file
31
.dmenu/dmenu_running_apps
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ____ _____
|
||||||
|
# | _ \_ _| Derek Taylor (DistroTube)
|
||||||
|
# | | | || | http://www.youtube.com/c/DistroTube
|
||||||
|
# | |_| || | http://www.gitlab.com/dwt1/
|
||||||
|
# |____/ |_|
|
||||||
|
#
|
||||||
|
# Search through open programs and switch to their tag in dwm.
|
||||||
|
# The package xorg-xlsclients is required!
|
||||||
|
|
||||||
|
application=$(
|
||||||
|
# List all running programs
|
||||||
|
xlsclients |\
|
||||||
|
# Fix Virtualbox and LibreOffice
|
||||||
|
sed -e 's/.*VirtualBox/foobar virtualbox/g' -e 's/.*soffice/foobar libreoffice/g' |\
|
||||||
|
# Remove flash from results
|
||||||
|
grep -v "plugin-container" |\
|
||||||
|
# Show only app-names
|
||||||
|
cut -d" " -f3 |\
|
||||||
|
# Pipe to dmenu ($@ to include font settings from dwm/config.h)
|
||||||
|
dmenu -i -p "switch to:" $@
|
||||||
|
)
|
||||||
|
|
||||||
|
# Switch to chosen application
|
||||||
|
case $application in
|
||||||
|
gimp | truecrypt)
|
||||||
|
xdotool search --onlyvisible -classname "$application" windowactivate &> /dev/null
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
xdotool search ".*${application}.*" windowactivate &> /dev/null
|
||||||
|
;;
|
||||||
28
.dmenu/todo
Executable file
28
.dmenu/todo
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Write/remove a task to do later.
|
||||||
|
#
|
||||||
|
# Select an existing entry to remove it from the file, or type a new entry to
|
||||||
|
# add it.
|
||||||
|
#
|
||||||
|
|
||||||
|
file="$HOME/.todo"
|
||||||
|
touch "$file"
|
||||||
|
height=$(wc -l "$file" | awk '{print $1}')
|
||||||
|
prompt="Add/delete a task: "
|
||||||
|
|
||||||
|
cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
|
||||||
|
while [ -n "$cmd" ]; do
|
||||||
|
if grep -q "^$cmd\$" "$file"; then
|
||||||
|
grep -v "^$cmd\$" "$file" > "$file.$$"
|
||||||
|
mv "$file.$$" "$file"
|
||||||
|
height=$(( height - 1 ))
|
||||||
|
else
|
||||||
|
echo "$cmd" >> "$file"
|
||||||
|
height=$(( height + 1 ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmd=$(dmenu -l "$height" -p "$prompt" "$@" < "$file")
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user