From 686f13e21c735658cad9b128617e7db7b3fe1bb0 Mon Sep 17 00:00:00 2001 From: TuDatTr Date: Fri, 22 May 2020 01:55:37 +0200 Subject: [PATCH] Added check in config/.scripts/*.sh scripts wether the needed commands are available Fixed shebang for some scrips Removed unnecessary config/.scripts/lock.sh and replaced lock.sh with i3lock.py in the script that executed lock.sh --- config/.local/share/ranger/bookmarks | 2 +- config/.scripts/i3lock.py | 2 ++ config/.scripts/lock.sh | 2 -- config/.scripts/screen.sh | 2 ++ config/.scripts/screenshot.sh | 4 ++++ config/.scripts/sound.sh | 4 ++++ config/.scripts/startup.sh | 8 +++++--- 7 files changed, 18 insertions(+), 6 deletions(-) delete mode 100755 config/.scripts/lock.sh diff --git a/config/.local/share/ranger/bookmarks b/config/.local/share/ranger/bookmarks index a0897ef..48accb6 100644 --- a/config/.local/share/ranger/bookmarks +++ b/config/.local/share/ranger/bookmarks @@ -9,5 +9,5 @@ t:/home/tuan/Templates w:/home/tuan/workspace_l/Projects k:/home/tuan/Documents/CTF/TryHackMe/VulnUniversity q:/home/tuan/.nextcloud/Quick Drop -':/home/tuan/Pictures/Screenshots +':/home/tuan/.scripts e:/home/tuan/Documents/CTF/TryHackMe/Ice/2_Recon diff --git a/config/.scripts/i3lock.py b/config/.scripts/i3lock.py index f71c21b..73c6088 100755 --- a/config/.scripts/i3lock.py +++ b/config/.scripts/i3lock.py @@ -1,3 +1,5 @@ +#!/bin/python3 + import time import os diff --git a/config/.scripts/lock.sh b/config/.scripts/lock.sh deleted file mode 100755 index ee9cd5a..0000000 --- a/config/.scripts/lock.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -/usr/bin/python /home/tuan/.scripts/i3lock.py; diff --git a/config/.scripts/screen.sh b/config/.scripts/screen.sh index 4cf4974..ee25138 100755 --- a/config/.scripts/screen.sh +++ b/config/.scripts/screen.sh @@ -1,5 +1,7 @@ #!/bin/sh +type xbacklight >/dev/null 2>&1 || { echo >&2 "I require xbacklight but it's not installed. Aborting."; exit 1; } +type dunstify >/dev/null 2>&1 || { echo >&2 "I require dunstify but it's not installed. Aborting."; exit 1; } case $1 in "up"*) diff --git a/config/.scripts/screenshot.sh b/config/.scripts/screenshot.sh index 45d6a7a..935b7d2 100755 --- a/config/.scripts/screenshot.sh +++ b/config/.scripts/screenshot.sh @@ -1,5 +1,9 @@ #!/bin/sh +type maim >/dev/null 2>&1 || { echo >&2 "I require maim but it's not installed. Aborting."; exit 1; } +type dunstify >/dev/null 2>&1 || { echo >&2 "I require dunstify but it's not installed. Aborting."; exit 1; } +type xclip >/dev/null 2>&1 || { echo >&2 "I require xclip but it's not installed. Aborting."; exit 1; } +type xdotool >/dev/null 2>&1 || { echo >&2 "I require xdotool but it's not installed. Aborting."; exit 1; } d=$HOME/Pictures/Screenshots/$(date +%G-%m); case $1 in diff --git a/config/.scripts/sound.sh b/config/.scripts/sound.sh index 5c1bbcb..17a69c0 100755 --- a/config/.scripts/sound.sh +++ b/config/.scripts/sound.sh @@ -1,5 +1,9 @@ #!/bin/sh +type pactl >/dev/null 2>&1 || { echo >&2 "I require pactl but it's not installed. Aborting."; exit 1; } +type amixer >/dev/null 2>&1 || { echo >&2 "I require amixer but it's not installed. Aborting."; exit 1; } +type dunstify >/dev/null 2>&1 || { echo >&2 "I require dunstify but it's not installed. Aborting."; exit 1; } + defaultSink=$(pactl info | grep 'Default Sink' | cut -d' ' -f3); curVolume=$(amixer get Master | grep -o \[0-9\]\\+% -m 1); diff --git a/config/.scripts/startup.sh b/config/.scripts/startup.sh index 39c9400..e7affb2 100755 --- a/config/.scripts/startup.sh +++ b/config/.scripts/startup.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/bin/sh + +type xset >/dev/null 2>&1 || { echo >&2 "I require xset but it's not installed. Aborting."; exit 1; } lower_battery_threshold=10 KBD=""; @@ -15,7 +17,7 @@ function kb_routine { esac if [ "$KBD" != "$oldKBD" ]; then - notify-send "$KBD"; + dunstify -r 1 "$KBD"; fi } @@ -23,7 +25,7 @@ function kb_routine { function battery_routine { capacity=$(< /sys/class/power_supply/BAT0/capacity) if [[ $capacity -lt lower_battery_threshold ]]; then - notify-send "$capacity"; + dunstify "$capacity"; fi }