diff --git a/README.md b/README.md index e6c6c11b5c647fb5c94050e72a0897dd13c4ac82..3d7c8f2fbc68d3312e2a75d5aa8838eea72c7aec 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ The scripts included in this repo are: + dm-confedit - Choose from a list of configuration files to edit. + dm-currencies - Convert prices between currencies. + dm-dictionary - Simple dictionary script ++ dm-documents - Searches for pdf files and opens them with the pdf viewer + dm-hub - A hub from where you can run all the scripts from. + dm-ip - Get IP of interface or external IP + dm-kill - Search for a process to kill. diff --git a/config/config b/config/config index b15c51f9b611a4f3d313b68e06b4839b18819466..682c0818a45038cf9dd9e9afa9de94b80b0fecb6 100755 --- a/config/config +++ b/config/config @@ -11,6 +11,8 @@ DMENU="dmenu -i -l 20 -p" +PDF_VIEWER="zathura" + DMBROWSER="brave" # DMBROWSER="qutebrowser" diff --git a/scripts/dm-documents b/scripts/dm-documents new file mode 100755 index 0000000000000000000000000000000000000000..cafe9fe6662a31f96f8cda8d02e405337b66b4be --- /dev/null +++ b/scripts/dm-documents @@ -0,0 +1,53 @@ +#!/bin/bash +# +# Script name: dm-documents +# Description: Search for a process to kill. +# Dependencies: dmenu +# GitLab: https://www.gitlab.com/dwt1/dmscripts +# License: https://www.gitlab.com/dwt1/dmscripts/LICENSE +# Contributors: Derek Taylor, HostGrady + +# Set with the flags "-e", "-u","-o pipefail" cause the script to fail +# if certain things happen, which is a good thing. Otherwise, we can +# get hidden bugs that are hard to discover. + +set -euo pipefail +_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo ".")")" && pwd)" +if [[ -f "${_path}/_dm-helper.sh" ]]; then + # shellcheck disable=SC1090,SC1091 + source "${_path}/_dm-helper.sh" +else + # shellcheck disable=SC1090 + echo "No helper-script found" +fi + +# script will not hit this if there is no config-file to load +# shellcheck disable=SC1090 +source "$(get_config)" + +main(){ + # PDF_VIEWER=zathura + files="$(find "$HOME" -maxdepth 4 -iname "*.pdf")" + choice=$( printf '%s\n' "${files[@]}" | \ + cut -d '/' -f4- | \ + sed -e 's/Documents/Dcs/g' \ + -e 's/Downloads/Dwn/g' \ + -e 's/Pictures/Pic/g' \ + -e 's/Images/Img/g' \ + -e 's/.pdf//g' | \ + sort -g | \ + ${DMENU} "File: " "$@") || exit 1 + if [ "$choice" ]; then + file=$( printf '%s' "$choice" | \ + sed -e 's/Dcs/Documents/g' \ + -e 's/Dwn/Downloads/g' \ + -e 's/Pic/Pictures/g' \ + -e 's/Img/Images/g' \ + ) + "${PDF_VIEWER}" "$HOME/${file}.pdf" + else + echo "Program Terminated." && exit 0 + fi +} + +[[ "${BASH_SOURCE[0]}" == "${0}" ]] && main "$@"