Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor modifications #25

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions comp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# General handler for compiling files

file=$(readlink -f "$1")
base=$(echo "$file" | sed 's/\..*//')
base=${file%.*}
#bang=$(sed -n "1p" "$file")

case "$1" in
*".md") pandoc "$file" -o "$base".pdf ;;
*".php") php -S "$file" ;;
*.md) pandoc "$file" -o "$base".pdf ;;
*.php) php -S "$file" ;;
*) echo "Can't compile" ;;
esac
14 changes: 7 additions & 7 deletions cpdragon
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
files=$(dragon-drag-and-drop -t -x)

for file in $files
do
path=${file#file://}
name=$(basename "$path")
cp "$path" "$(pwd)/$name"
done
while IFS= read line; do
path=${line##file://}
name=${path##*/}
cp "$path" "$name"
done << EOF
$(dragon-drag-and-drop -t -x)
EOF
2 changes: 1 addition & 1 deletion crf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
# Script to generate a templte react class
printf "import React from \"react\";\n\nconst $1 = () => {\n\treturn <div></div>;\n};\n\nexport default $1;" > $(pwd)/$2/$1.js
printf "import React from \"react\";\n\nconst $1 = () => {\n\treturn <div></div>;\n};\n\nexport default $1;" > "$2/$1.js"
34 changes: 13 additions & 21 deletions dlfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
#!/bin/sh
# Provides the ability to download a file by dropping it into a window

url=$(dragon-drag-and-drop -t -x)
url="$(dragon-drag-and-drop -t -x)"

if [ -n "$url" ]; then
printf "File Name: "
name=""
while [ -z $name ] || [ -e $name ]
do
[ -n "$url" ] || exit 1

name=""
while [ -z "$name" ] || [ -e "$name" ]
do
printf "File Name: "
read -r name
if [ -e "$name" ]; then
printf "File already exists, overwrite (y|n): "
read -r ans

if [ "$ans" = "y" ]; then
break
else
printf "File Name: "
fi
printf "File already exists, overwrite (y|n): "
read -r ans
[ "$ans" = "y" ] && break
fi
done

# Download the file with curl
[ -n "$name" ] && curl -o "$name" "$url" || exit 1
else
exit 1
fi
done

# Download the file with curl
[ -n "$name" ] && curl -s -o "$name" "$url" || exit 1
2 changes: 1 addition & 1 deletion encode
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# Performs HTML encoding on a string for special characters up to ASCII

echo "$1" | sed 's/%/%25/g;s/\s/%20/g;s/!/%21/g;s/"/%22/g;s/#/%22/g;s/\$/%24/g;s/&/%26/g;s/\x27/%27/g;s/)/%29/g;s/(/%28/g;s/\*/%2A/g;s/\+/%2B/g;s/,/%2C/g;s/-/%2D/g;s/\./%2E/g;s/\//%2F/g;s/:/%3A/g;s/;/%3B/g;s/</%3C/g;s/=/%3D/g;s/>/%3E/g;s/\?/%3F/g;s/@/%40/g;s/]/%5D/g;s/\\/%5C/g;s/\[/%5B/g;s/\^/%5E/g;s/_/%5F/g;s/`/%60/g;s/}/%7D/g;s/|/%7C/g;s/{/%7B/g;s/~/%7E/g'
sed 's/%/%25/g;s/\s/%20/g;s/!/%21/g;s/"/%22/g;s/#/%22/g;s/\$/%24/g;s/&/%26/g;s/\x27/%27/g;s/)/%29/g;s/(/%28/g;s/\*/%2A/g;s/\+/%2B/g;s/,/%2C/g;s/-/%2D/g;s/\./%2E/g;s/\//%2F/g;s/:/%3A/g;s/;/%3B/g;s/</%3C/g;s/=/%3D/g;s/>/%3E/g;s/\?/%3F/g;s/@/%40/g;s/]/%5D/g;s/\\/%5C/g;s/\[/%5B/g;s/\^/%5E/g;s/_/%5F/g;s/`/%60/g;s/}/%7D/g;s/|/%7C/g;s/{/%7B/g;s/~/%7E/g'
8 changes: 4 additions & 4 deletions extramonitor
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
intern="$2"
extern="$3"

case "$1" in
"disconnect") xrandr --output "$extern" --off --output "$intern" --auto ;;
"extra") xrandr --output "$extern" --set audio force-dvi --mode 1920x1080 && xrandr --output "$intern" --auto --output "$extern" --right-of "$intern" ;;
"duplicate") xrandr --output "$extern" --set audio force-dvi --mode 1920x1080 && xrandr --output "$intern" --auto --output "$extern" --same-as "$intern" ;;
case $1 in
disconnect) xrandr --output "$extern" --off --output "$intern" --auto ;;
extra) xrandr --output "$extern" --set audio force-dvi --mode 1920x1080 && xrandr --output "$intern" --auto --output "$extern" --right-of "$intern" ;;
duplicate) xrandr --output "$extern" --set audio force-dvi --mode 1920x1080 && xrandr --output "$intern" --auto --output "$extern" --same-as "$intern" ;;
*) notify-send "Multi Monitor" "Unknown Operation" ;;
esac
2 changes: 1 addition & 1 deletion mepapemaker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/bash

pape=$1
pape="$1"

# Get the width of the wallpaper
height=$(magick convert "$pape" -format "%h" info:)
Expand Down
17 changes: 6 additions & 11 deletions mkscript
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
#!/bin/sh
# Simple script to generate a script file in my scripts directory

printf "File Name: "

# Set a name for the script
ans=
while [ -z "$ans" ];
do
read -r ans

if [ -z "$ans" ]; then
printf "File Name: "
fi
read -r ans
done

file=$HOME/scripts/$ans

if [ -d "$HOME/scripts" ]; then
if [ -e "$HOME/scripts/$ans" ]; then
[ -d "$HOME/scripts" ] && exit
if [ -e "$HOME/scripts/$ans" ]; then
$EDITOR "$file"
else
echo "#!/bin/sh" >> "$file"
else
echo '#!/bin/sh' >> "$file"
chmod +x "$file"
$EDITOR "$file"
fi
fi
7 changes: 1 addition & 6 deletions mntandroid
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
#!/bin/sh
# Mount and unmount an android device to the $HOME/cell folder

dir=$HOME/cell

# Make the cell directory if it doesn't exist
if [ -d "$dir" ]; then
mkdir "$dir"
fi
mkdir -p "$HOME/cell"

if [ "$(find "$dir" -maxdepth 1 | wc -l)" -gt 1 ]; then
fusermount -u "$dir" && notify-send "Android Mount" "Device Unmounted"
Expand Down
15 changes: 7 additions & 8 deletions mvdragon
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/sh

files=$(dragon-drag-and-drop -t -x)

for file in $files
do
path=${file#file://}
name=$(basename "$path")
mv "$path" "$(pwd)/$name"
done
while IFS= read line; do
path=${line##file://}
name=${path##*/}
mv "$path" "$name"
done << EOF
$(dragon-drag-and-drop -t -x)
EOF
20 changes: 10 additions & 10 deletions opnbrow
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# Handler script for opening a link in a browser

handle_default() {
if [ ! -z "$1" ]; then
if command -v "$1" >/dev/null; then
$1 "$2"
elif [ ! -z "$BROWSER" ]; then
$BROWSER $2
elif [ -n "$BROWSER" ]; then
$BROWSER "$2"
fi
}

if [ "$2" ]; then
# Special handling for browsers that support tabbing
case "$1" in
"firefox") firefox --new-tab "$2" ;;
*) handle_default ;;
esac
fi
[ "$2" ] || exit

# Special handling for browsers that support tabbing
case $1 in
firefox) firefox --new-tab "$2" ;;
*) handle_default "$@" ;;
esac
7 changes: 5 additions & 2 deletions opout
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
# opout: "open output": A general handler for opening a file's intended output.
# I find this useful especially running from vim.

basename="$(echo "$1" | sed 's/\.[^\/.]*$//')"
# Avoid extension-less hidden filenames from being read as null.
basename_nodot=${1#.}

case "$1" in
basename=${basename_nodot%.*}

case $1 in
*.tex|*.md|*.rmd|*.ms|*.me|*.mom) setsid "$READER" "$basename".pdf >/dev/null 2>&1 & ;;
*.html) setsid "$BROWSER" --new-window "$basename".html >/dev/null 2>&1 & ;;
esac
4 changes: 1 addition & 3 deletions prompt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
# Opens a basic yes/no prompt with dmenu
# This is useful for confirming whether an action should be taken

if [ "$(printf "No\nYes" | dmenu -i -p "$1" -fn "JetBrains Mono Medium-10")" = "Yes" ]; then
$2
fi
[ "$(printf 'No\nYes' | dmenu -i -p "$1" -fn 'JetBrains Mono Medium-10')" = 'Yes' ] && "$2"
3 changes: 2 additions & 1 deletion pyshell
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
echo "" | dmenu -i -p "Python" | xargs -0 -I % python -c "import random;print(%)" | xargs -I % notify-send "Result" "%"
notify-send 'Result' \
"$(printf '' | dmenu -p 'Python' | xargs -I % python -c "import random; print(%)")"
16 changes: 8 additions & 8 deletions sch
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# Opens a dmenu prompt for selecting a search engine and providing a search query
# To avoid issues with spaces and special characters html encoding is applied to the query

hist=$HOME/.config/search/search_history

url=$(sort ~/.config/search/search | sed 's/:.*//' | dmenu -i -p "Search Engine" | xargs -I % grep "%:" ~/.config/search/search | sed 's/.*://')
search=$(sort ~/.config/search/search_history | dmenu -i -p "Search")
search=$(sort "$hist" | dmenu -i -p "Search")

# Echo to history file
if [ ! "$(grep -q "$search" < ~/.config/search/search_history)" ]; then
if [ "$(wc -l < ~/.config/search/search_history)" -gt 500 ]; then
sed -i "1s/^/$search\n/;$ d" ~/.config/search/search_history
if ! grep -q "$search" "$hist"; then
if [ $(wc -l "$hist") -gt 500 ]; then
sed -i "1s/^/$search\n/;$ d" "$hist"
else
echo "$search" >> ~/.config/search/search_history
echo "$search" >> "$hist"
fi
fi

# Open browser if search query provided
if [ -n "$search" ] && [ "$search" != "" ]; then
opnbrow "$1" "$url$(encode "$search")"
fi
[ -n "$search" ] && opnbrow "$1" "$url$(encode "$search")"
15 changes: 7 additions & 8 deletions screenshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
output=$HOME/pictures/screenshots/"$(date +%s_%h%d_%H:%M:%S).png"

menu() {
echo "" | dmenu -p "How Long?" | xargs -I _ sleep "_"
printf '' | dmenu -p "How Long?" | xargs -I _ sleep "_"
}

case "$1" in
"full") maim "$output" || exit;;
"select") maim -s "$output" || exit ;;
"fulltime") menu && maim "$output" || exit ;;
"selecttime") menu && maim -s "$output" || exit ;;

case $1 in
full) maim "$output" || exit;;
select) maim -s "$output" || exit ;;
fulltime) menu && maim "$output" || exit ;;
selecttime) menu && maim -s "$output" || exit ;;
esac

notify-send "Maim" "Screenshot Taken"
notify-send Maim 'Screenshot Taken'
2 changes: 1 addition & 1 deletion stripspace
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
# Renames a file by stripping out the spaces
newname=$(echo "$1" | sed 's/ /-/g')
newname="$(printf "$1" | tr ' ' '-')"
mv "$1" "$newname"
2 changes: 1 addition & 1 deletion toggletouch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
id="$(xinput list | grep -Eo 'Touchpad.*id=[0-9]*' | grep -Eo '[0-9]*')"
mode="$(echo "$id" | xargs -I % xinput --list-props % | grep 'Device Enabled' | grep -Eo ':.*[0|1]' | grep -Eo '[0|1]')"

if [ "$mode" -eq "1" ]; then
if [ $mode -eq 1 ]; then
xinput set-prop "$id" "Device Enabled" 0 && notify-send "Touchpad" "Touchpad has been disabled"
else
xinput set-prop "$id" "Device Enabled" 1 && notify-send "Touchpad" "Touchpad has been enabled"
Expand Down