aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2018-11-19 14:13:18 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2018-11-19 14:13:18 +0100
commit683564bd058884356491b7b847f5d2e204207389 (patch)
treec7d60ec611dc6c72fcf885d30051fae9757d67c1
downloadscripts-683564bd058884356491b7b847f5d2e204207389.tar.gz
scripts-683564bd058884356491b7b847f5d2e204207389.zip
Initial scripts commit.
-rw-r--r--bgBrowser.sh101
-rw-r--r--bgSelector.sh7
-rw-r--r--brightFirst.sh2
-rw-r--r--brightness.sh20
-rw-r--r--dmenuMount.sh34
-rw-r--r--dmenuTerm.sh30
-rw-r--r--dmenuUmount.sh22
-rw-r--r--months.sh41
-rw-r--r--neofetch.sh13
-rw-r--r--notification.sh3
-rw-r--r--pkmBgSelector.sh11
-rw-r--r--prompt.sh10
-rw-r--r--resetConnection.sh3
-rw-r--r--showColors.sh11
-rw-r--r--syncthing.sh2
-rw-r--r--systemControl.sh19
-rw-r--r--webview.sh22
-rw-r--r--wifiDown.sh2
-rw-r--r--years.sh28
19 files changed, 381 insertions, 0 deletions
diff --git a/bgBrowser.sh b/bgBrowser.sh
new file mode 100644
index 0000000..3608e30
--- /dev/null
+++ b/bgBrowser.sh
@@ -0,0 +1,101 @@
+#!/bin/bash
+# _ _
+# __ ____ _| | |_ __ __ _ _ __ ___ _ __
+# \ \ /\ / / _` | | | '_ \ / _` | '_ \ / _ \ '__|
+# \ V V / (_| | | | |_) | (_| | |_) | __/ |
+# \_/\_/ \__,_|_|_| .__/ \__,_| .__/ \___|_|
+# _ |_| |_|
+# | |__ _ __ _____ _____ ___ _ __
+# | '_ \| '__/ _ \ \ /\ / / __|/ _ \ '__|
+# | |_) | | | (_) \ V V /\__ \ __/ |
+# |_.__/|_| \___/ \_/\_/ |___/\___|_|
+#
+
+folder="/home/inigo/images/wallpapers/"
+indexSet=0
+
+function updateFiles {
+ files=$(ls "$folder" | grep -e .jpg -e .jpeg -e .png)
+}
+
+function updateCurrentFile {
+ i=0
+ for file in $files; do
+ i=$(($i+1))
+ if [ $i -eq $indexSet ]; then
+ selectedFile="$file"
+ fi
+ done
+}
+
+function updateBg {
+ feh --bg-scale "$folder""$selectedFile"
+ echo "New bg: $selectedFile"
+}
+
+echo "Welcome to bg browser! Usage:"
+echo "h, l - Browse wallpapers."
+echo "r - Rename current wallpaper's file."
+echo "d - Delete current wallpaper's file."
+echo "q - Quit."
+
+updateFiles
+read -n 1 input
+while [ "$input" != "q" ]
+do
+ case $input in
+ l)
+ indexSet=$(($indexSet+1))
+ clear
+ updateCurrentFile
+ updateBg
+ ;;
+ h)
+ indexSet=$(($indexSet-1))
+ clear
+ updateCurrentFile
+ updateBg
+ ;;
+ r)
+ clear && echo "Rename? [y]es/[no]"
+ read -n 1 input
+ if [ "$input" = "y" ]; then
+ clear && echo "Prev name: $selectedFile" && echo "New name: "
+ read newName
+ if [ "$newName" = "$selectedFile" ]; then
+ clear && echo "Same name ("$newName") - No changes"
+ else
+ # Check that name does not exist
+ if [ -f "$folder$newName" ]; then #FIX
+ clear && echo "\"$newName\" already exists - Aborting"
+ else
+ mv "$folder$selectedFile" "$folder$newName"
+ echo "$selectedFile -> $newName"
+ updateFiles
+ updateCurrentFile
+ updateBg
+ fi
+ fi
+ else
+ clear && echo "Current bg: $selectedFile"
+ fi
+ ;;
+ d)
+ clear && echo "Delete $selectedFile? [y]es/[no]"
+ read -n 1 input
+ if [ "$input" = "y" ]; then
+ rm "$folder$selectedFile"
+ clear && echo "\"$selectedFile\" deleted"
+ updateFiles
+ updateCurrentFile
+ updateBg
+ else
+ clear && echo "Not deleted." && echo "Current bg: $selectedFile"
+ fi
+ ;;
+ *)
+ clear && echo "Current bg: $selectedFile"
+ ;;
+ esac
+ read -n 1 input
+done
diff --git a/bgSelector.sh b/bgSelector.sh
new file mode 100644
index 0000000..541a96b
--- /dev/null
+++ b/bgSelector.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [ $(date +%H) -gt 18 ]
+then
+ feh --bg-scale ~/images/wallpapers/night*
+else
+ feh --bg-scale ~/images/wallpapers/bg*
+fi
diff --git a/brightFirst.sh b/brightFirst.sh
new file mode 100644
index 0000000..5dd2540
--- /dev/null
+++ b/brightFirst.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo chmod 666 /sys/class/backlight/intel_backlight/brightness
diff --git a/brightness.sh b/brightness.sh
new file mode 100644
index 0000000..b104d22
--- /dev/null
+++ b/brightness.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+brightness_file=/sys/class/backlight/intel_backlight/brightness
+maxbrightness_file=/sys/class/backlight/intel_backlight/max_brightness
+
+brightness=$(< $brightness_file)
+maxbrightness=$(< $maxbrightness_file)
+let target=$1+$brightness
+#for testing:
+#echo "Actual bright: $brightness; Max: $maxbrightness; Target: $target"
+if [ $target -gt $maxbrightness ]
+then
+ echo "Value too big. Target: $target; max: $maxbrightness"
+elif [ 0 -gt $target ]
+then
+ echo "Value too low. Target: $target"
+else
+ echo $target | tee $brightness_file
+ echo "New brightness: $target/$maxbrightness"
+fi
diff --git a/dmenuMount.sh b/dmenuMount.sh
new file mode 100644
index 0000000..00c1e73
--- /dev/null
+++ b/dmenuMount.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# _
+# __| |_ __ ___ ___ _ __ _ _
+# / _` | '_ ` _ \ / _ \ '_ \| | | |
+# | (_| | | | | | | __/ | | | |_| |
+# \__,_|_| |_| |_|\___|_| |_|\__,_|
+# _
+# _ __ ___ ___ _ _ _ __ | |_ ___
+# | '_ ` _ \ / _ \| | | | '_ \| __/ __|
+# | | | | | | (_) | |_| | | | | |_\__ \
+# |_| |_| |_|\___/ \__,_|_| |_|\__|___/
+#
+#
+# Gives a dmenu prompt to mount unmounted drives.
+# If they're in /etc/fstab, they'll be mounted automatically.
+# Otherwise, prompts to give a mountpoint from already existing directories.
+# If you input a novel directory, prompts to create that directory.
+
+pgrep -x dmenu && exit
+
+mountable=$(lsblk -lp | grep "part $" | awk '{print $1, "(" $4 ")"}')
+[[ "$mountable" = "" ]] && exit 1
+chosen=$(echo "$mountable" | dmenu -i -p "Mount which drive?" | awk '{print $1}')
+[[ "$chosen" = "" ]] && exit 1
+#sudo -u inigo mount "$chosen" && exit 0
+mount "$chosen" && notify-send "$chosen mounted" && exit 0
+dirs=$(find /media /home/inigo/mounts -type d -maxdepth 3 -empty 2>/dev/null)
+mountpoint=$(echo "$dirs" | dmenu -i -p "Type in mount point.")
+[[ "$mountpoint" = "" ]] && exit 1
+if [[ ! -d "$mountpoint" ]]; then
+ bash /home/inigo/scripts/prompt.sh "$mountpoint does not exist. Create it?" "mkdir -p $mountpoint"
+fi
+#sudo -u inigo mount $chosen $mountpoint && pgrep -x dunst && notify-send "$chosen mounted to $mountpoint."
+mount $chosen $mountpoint && pgrep -x dunst && notify-send "$chosen mounted to $mountpoint."
diff --git a/dmenuTerm.sh b/dmenuTerm.sh
new file mode 100644
index 0000000..f01a916
--- /dev/null
+++ b/dmenuTerm.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# dmenu script for opening console programs and scripts directly
+
+options="neofetch\ncmus\nnewsboat\nneomutt\nsyncthing\nbrightFirst\nresetConnection\nwifiDown\nyears\nmonths\nbg selection\nshowColors"
+
+chosen=$(echo -e "$options" | dmenu \
+-i \
+-p "~$" \
+-nb "#000000" \
+-nf "#60ff00" \
+-sb "#60f000" \
+-sf "#000000")
+
+case "$chosen" in
+ # floating windows
+ neofetch) urxvt -name floating -sh 30 -cr black -geometry 80x21 -e bash ~/scripts/neofetch.sh ;;
+ showColors) urxvt -name floating -sh 10 -cr black -geometry 43x9 -e bash ~/scripts/showColors.sh ;;
+ years) urxvt -name floating -sh 20 -cr black -geometry 66x39 -e bash ~/scripts/years.sh ;;
+ months) urxvt -name floating -sh 20 -cr black -geometry 22x9 -e bash ~/scripts/months.sh ;;
+ "bg selection") urxvt -name floating -sh 20 -cr black -geometry 45x6 -e bash ~/scripts/bgBrowser.sh ;;
+ #programs
+ cmus) urxvt -cd ~/music -e cmus ;;
+ newsboat) urxvt -e newsboat ;;
+ neomutt) urxvt -e neomutt ;;
+ syncthing) qutebrowser && urxvt -e bash ~/scripts/syncthing.sh ;;
+ # sudo stuff
+ brightFirst) urxvt -name floating -geometry 32x1 -e sudo bash ~/scripts/brightFirst.sh ;;
+ resetConnection) urxvt -name floating -geometry 32x1 -e sudo bash ~/scripts/resetConnection.sh ;;
+ wifiDown) urxvt -name floating -geometry 32x1 -e sudo bash ~/scripts/wifiDown.sh ;;
+esac
diff --git a/dmenuUmount.sh b/dmenuUmount.sh
new file mode 100644
index 0000000..873ad2d
--- /dev/null
+++ b/dmenuUmount.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# _ _
+# __| |_ __ ___ ___ _ __ _ _
+# / _` | '_ ` _ \ / _ \ '_ \| | | |
+# | (_| | | | | | | __/ | | | |_| |
+# \__,_|_| |_| |_|\___|_| |_|\__,_|
+# _
+# _ _ _ __ ___ ___ _ _ _ __ | |_ ___
+# | | | | '_ ` _ \ / _ \| | | | '_ \| __/ __|
+# | |_| | | | | | | (_) | |_| | | | | |_\__ \
+# \__,_|_| |_| |_|\___/ \__,_|_| |_|\__|___/
+#
+# Gives a dmenu prompt to umount mounted drives.
+# Shows mounted partitions; select one to unmount.
+
+exclusionregex="\(/boot\|/home\|/\)$"
+drives=$(lsblk -lp | grep "part /" | grep -v "$exclusionregex" | awk '{print $1, "(" $4 ")", "on", $7}')
+[[ "$drives" = "" ]] && exit
+chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}')
+[[ "$chosen" = "" ]] && exit
+umount $chosen && pgrep -x dunst && notify-send "$chosen unmounted."
+#umount $chosen && notify-send "$chosen unmounted."
diff --git a/months.sh b/months.sh
new file mode 100644
index 0000000..b9d822b
--- /dev/null
+++ b/months.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# _ _
+# _ __ ___ ___ _ __ | |_| |__ ___
+# | '_ ` _ \ / _ \| '_ \| __| '_ \/ __|
+# | | | | | | (_) | | | | |_| | | \__ \
+# |_| |_| |_|\___/|_| |_|\__|_| |_|___/
+#
+# Navigates through month calendars and exits with q
+
+month=$(date +%m)
+year=$(date +%Y)
+ncal -b -m $month $year
+read -n 1 input
+
+while [ "$input" != "q" ]
+do
+ case $input in
+ l)
+ clear
+ month=$(($month%12+1))
+ if [ $month -eq 1 ]
+ then
+ year=$(($year+1))
+ fi
+ ncal -b -m $month $year
+ read -n 1 input
+ ;;
+ h)
+ clear
+ month=$(($(($month-1))%12))
+ if [ $month -eq 0 ]
+ then
+ month=12
+ year=$(($year-1))
+ fi
+ ncal -b -m $month $year
+ read -n 1 input
+ ;;
+ esac
+done
+
diff --git a/neofetch.sh b/neofetch.sh
new file mode 100644
index 0000000..e5f8edc
--- /dev/null
+++ b/neofetch.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+# Wrapper for neofetch
+
+neofetch \
+--disable term \
+--block_width 3 \
+--block_height 1 \
+--block_range 0 15 \
+--underline_char o \
+--gtk2 off \
+--gtk3 off
+
+read -rsp "" -d "q"
diff --git a/notification.sh b/notification.sh
new file mode 100644
index 0000000..99ad0f4
--- /dev/null
+++ b/notification.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+chosen=myselection
+pgrep -x dunst && notify-send "$chosen mynotif."
diff --git a/pkmBgSelector.sh b/pkmBgSelector.sh
new file mode 100644
index 0000000..7fea1b9
--- /dev/null
+++ b/pkmBgSelector.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+hour=$(date +%H)
+if [ $hour -gt 4 -a $hour -lt 7 ]; then
+ feh --bg-scale ~/images/wallpapers/pkmduskbg.png
+elif [ $hour -gt 6 -a $hour -lt 15 ]; then
+ feh --bg-scale ~/images/wallpapers/pkmdaybg.png
+elif [ $hour -gt 14 -a $hour -lt 17 ]; then
+ feh --bg-scale ~/images/wallpapers/pkmduskbg.png
+else
+ feh --bg-scale ~/images/wallpapers/pkmnightbg.jpg
+fi
diff --git a/prompt.sh b/prompt.sh
new file mode 100644
index 0000000..6d262c1
--- /dev/null
+++ b/prompt.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+# A dmenu binary prompt script.
+# Gives a dmenu prompt labeled with $1 to perform command $2.
+
+[ $(echo -e "No\nYes" | dmenu -i -p "$1" \
+-nb "#000000" \
+-nf "#60ff00" \
+-sb "#60f000" \
+-sf "#000000") \
+== "Yes" ] && $2
diff --git a/resetConnection.sh b/resetConnection.sh
new file mode 100644
index 0000000..7037006
--- /dev/null
+++ b/resetConnection.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+sudo ifconfig wlp2s0 up
+service network-manager restart
diff --git a/showColors.sh b/showColors.sh
new file mode 100644
index 0000000..1b0a19a
--- /dev/null
+++ b/showColors.sh
@@ -0,0 +1,11 @@
+#!bin/bash
+echo -e "\033[0;30mBlack (0;30) \033[1;30mLight Black (1;30)"
+echo -e "\033[0;31mRed (0;31) \033[1;31mLight Red (1;31)"
+echo -e "\033[0;32mGreen (0;32) \033[1;32mLight Green (1;32)"
+echo -e "\033[0;33mOrange (0;33) \033[1;33mLight Orange (1;33)"
+echo -e "\033[0;34mBlue (0;34) \033[1;34mLight Blue (1;34)"
+echo -e "\033[0;35mPurple (0;35) \033[1;35mLight Purple (1;35)"
+echo -e "\033[0;36mCyan (0;36) \033[1;36mLight Cyan (1;36)"
+echo -e "\033[0;37mWhite (0;37) \033[1;37mLight White (1;37)"
+
+read -rsp "" -d "q"
diff --git a/syncthing.sh b/syncthing.sh
new file mode 100644
index 0000000..a0b0924
--- /dev/null
+++ b/syncthing.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+~/syncthing/syncthing-linux-amd64-v0.14.51/syncthing
diff --git a/systemControl.sh b/systemControl.sh
new file mode 100644
index 0000000..2b4125f
--- /dev/null
+++ b/systemControl.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# A dmenu prompt script to control system functions.
+
+options="lock\nreboot\nshutdown\nexit i3"
+
+chosen=$(echo -e "$options" | dmenu \
+-i \
+-p ">_" \
+-nb "#000000" \
+-nf "#60ff00" \
+-sb "#60f000" \
+-sf "#000000")
+
+case "$chosen" in
+ lock) i3lock -i ~/images/wallpapers/lockbg.png -f ;;
+ reboot) bash ~/scripts/prompt.sh Reboot? reboot ;;
+ shutdown) bash ~/scripts/prompt.sh Shutdown? "shutdown now" ;;
+ "exit i3") bash ~/scripts/prompt.sh "Exit i3? (ends X session)" "i3-msg exit" ;;
+esac
diff --git a/webview.sh b/webview.sh
new file mode 100644
index 0000000..611deb1
--- /dev/null
+++ b/webview.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Feed script a url.
+
+ext="${1##*.}"
+mpvFiles="mkv mp4 gif"
+pqivFiles="png jpg jpeg jpe"
+wgetFiles="mp3 pdf"
+
+# Check youtube link
+if echo "$1" | grep youtube > /dev/null; then
+ nohup mpv --loop "$1" >/dev/null &
+# General checks
+elif echo $pqivFiles | grep -w $ext > /dev/null; then
+ i3 exec pqiv "$1" >/dev/null &
+elif echo $mpvFiles | grep -w $ext > /dev/null; then
+ i3 exec mpv --loop "$1" >/dev/null &
+elif echo $wgetFiles | grep -w $ext > /dev/null; then
+ i3 exec wget "$1" >/dev/null &
+else
+ i3 exec qutebrowser "$1" >/dev/null &
+fi
diff --git a/wifiDown.sh b/wifiDown.sh
new file mode 100644
index 0000000..d8b22d9
--- /dev/null
+++ b/wifiDown.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+sudo ifconfig wlp2s0 down
diff --git a/years.sh b/years.sh
new file mode 100644
index 0000000..49494cb
--- /dev/null
+++ b/years.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# _ _ ___ __ _ _ __ ___
+# | | | |/ _ \/ _` | '__/ __|
+# | |_| | __/ (_| | | \__ \
+# \__, |\___|\__,_|_| |___/
+# |___/
+#
+# Navigates through year calendars and exits with q
+
+year=$(date +%Y)
+ncal -b -y
+read -n 1 input
+
+while [ "$input" != "q" ]
+do
+ case $input in
+ l)
+ year=$(($year+1))
+ ;;
+ h)
+ year=$(($year-1))
+ ;;
+ esac
+ clear
+ ncal -b -y $year
+ read -n 1 input
+done
+