From e88acdea18983b4e405098accef9ad0b21e73a4a Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Mon, 15 Apr 2019 10:46:09 +0200 Subject: Minor upgrades. --- brightness.sh | 20 +++++++++----------- cmusPlay.sh | 2 +- dmenuDic.sh | 2 +- emoji.sh | 6 +++--- rm.sh | 8 ++++++++ shufEmoji.sh | 7 +++++++ syncthing.sh | 5 +++-- vol.sh | 6 +++--- 8 files changed, 35 insertions(+), 21 deletions(-) create mode 100755 rm.sh create mode 100755 shufEmoji.sh diff --git a/brightness.sh b/brightness.sh index a1c6648..cf2480f 100755 --- a/brightness.sh +++ b/brightness.sh @@ -9,20 +9,18 @@ maxbrightness_file="/sys/class/backlight/intel_backlight/max_brightness" # sudo ~/scripts/brightFirst.sh # fi -brightness=$(< "$brightness_file") -maxbrightness=$(< "$maxbrightness_file") -let target=$1+$brightness -sudo chmod 666 /sys/class/backlight/intel_backlight/brightness -if [ $target -gt $maxbrightness ] +brightness="$(cat "$brightness_file")" +maxbrightness="$(cat "$maxbrightness_file")" +target=$(($1+brightness)) +if [ $target -gt "$maxbrightness" ] then - sudo echo "$maxbrightness" >"$brightness_file" -elif [ 0 -gt $target ] + echo "$maxbrightness" | sudo tee "$brightness_file" +elif [ 0 -gt "$target" ] then - sudo echo "0" >"$brightness_file" + echo "0" | sudo tee "$brightness_file" else - sudo echo "$target" >"$brightness_file" + echo "$target" | sudo tee "$brightness_file" fi -sudo chmod 644 /sys/class/backlight/intel_backlight/brightness -dunstify -r $(dunstifyIDs.sh "brightness") -t 500 "$(~/scripts/i3blocks/i3brightness.sh)" +dunstify -r "$(dunstifyIDs.sh "brightness")" -t 500 "$(~/scripts/i3blocks/i3brightness.sh)" pkill -SIGRTMIN+11 i3blocks diff --git a/cmusPlay.sh b/cmusPlay.sh index 2996651..64f5b2c 100755 --- a/cmusPlay.sh +++ b/cmusPlay.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if ! pgrep -x cmus ; then urxvt -title floating -sh 20 -geometry "185x15+30-28" -cd ~/music -e cmus diff --git a/dmenuDic.sh b/dmenuDic.sh index cbfce71..586d0c5 100755 --- a/dmenuDic.sh +++ b/dmenuDic.sh @@ -2,7 +2,7 @@ # Selects a word from the system's dictionary with the help of dmenu and copies it to clipboard. -word="$(cat /usr/share/dict/cracklib-small | dmenu -i -l 10 -p "Choose a word:")" +word="$(dmenu -i -l 10 -p "Choose a word:" < /usr/share/dict/cracklib-small)" [ "$word" ] || exit 0 echo "$word" | xsel -bi dunstify -t 2000 "Written [$word] into clipboard." diff --git a/emoji.sh b/emoji.sh index 6cc6ca5..99a69a1 100755 --- a/emoji.sh +++ b/emoji.sh @@ -3,7 +3,7 @@ # Feeds an emoji list into dmenu and allows to select one into clipboard file="$XDG_CONFIG_HOME/emoji" -selected="$(cat "$file" | dmenu -i -l 20 -p "Choose an emoji:" | cut -d' ' -f1)" -[ -z "$selected" ] && dunstify "No emoji selected." && exit 0 +selected="$(dmenu -i -l 20 -p "Choose an emoji:" < "$file" | cut -d' ' -f1 | tr -d '\n')" +[ -z "$selected" ] && dunstify -t 2000 "No emoji selected." && exit 0 echo "$selected" | xsel -ib -dunstify "Copied $(xsel -ob)" +dunstify -t 2000 "Copied $(xsel -ob)" diff --git a/rm.sh b/rm.sh new file mode 100755 index 0000000..7d694ee --- /dev/null +++ b/rm.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# Moves an element to a litter folder instead of permanently removing it + +folder="$HOME/litter/" +[ -d "$folder" ] || mkdir "$folder" +mv "$1" "$folder" +pkill -SIGRTMIN+14 i3blocks diff --git a/shufEmoji.sh b/shufEmoji.sh new file mode 100755 index 0000000..04dbc07 --- /dev/null +++ b/shufEmoji.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Echoes some random emojis + +file="$XDG_CONFIG_HOME/emoji" +count=$1 +cut -d' ' -f1 < "$file" | shuf -n "$count" | tr -d '\n' diff --git a/syncthing.sh b/syncthing.sh index a0b0924..f593af9 100755 --- a/syncthing.sh +++ b/syncthing.sh @@ -1,2 +1,3 @@ -#!/bin/bash -~/syncthing/syncthing-linux-amd64-v0.14.51/syncthing +#!/bin/sh + +i3-msg "workspace 5" && urxvt -e ~/syncthing/syncthing-linux-amd64-v1.1.1/syncthing diff --git a/vol.sh b/vol.sh index 00d97bf..6ba41a6 100755 --- a/vol.sh +++ b/vol.sh @@ -1,10 +1,10 @@ #!/bin/sh sink="$(pactl list sinks | grep "^Sink " | cut -d'#' -f2)" -if [ $1 = "mute" ]; then +if [ "$1" = "mute" ]; then pactl set-sink-mute "$sink" toggle else - pactl set-sink-volume "$sink" $1% + pactl set-sink-volume "$sink" "$1%" fi -dunstify -r $(dunstifyIDs.sh "vol") -t 500 "$(~/scripts/i3blocks/i3vol.sh)" +dunstify -r "$(dunstifyIDs.sh "vol")" -t 500 "$(~/scripts/i3blocks/i3vol.sh)" pkill -SIGRTMIN+10 i3blocks -- cgit v1.2.1