mirror of
https://github.com/sbrl/bin.git
synced 2018-01-10 21:33:46 +00:00
Add recvdir & brightness.sh
This commit is contained in:
parent
20609abfe6
commit
e3f3da94fa
3 changed files with 58 additions and 0 deletions
|
@ -42,6 +42,8 @@ Here's a list of the most interesting ones, along with what they do and where th
|
|||
- organise-photos - A small bash script I wrote that organises the photos in a directory by year & month.
|
||||
- [ogg-cover-art](https://github.com/acabal/scripts/blob/master/ogg-cover-art) - A script that adds cover art to ogg files.
|
||||
- senddir - A small script I wrote to send whole directories over the network as a temporary thing. Uses netcat + gzip + tar.
|
||||
- recvdir - The counterpart to the above that receives the directory sent.
|
||||
- brightness.sh - Another small script I've written that controls the brightness of my screen. It works for me, but it may not work for you.
|
||||
|
||||
## Disclaimer
|
||||
I don't own many of the tools in this repository. If you are an owner of one of these tools and I haven't linked to you, please let me know as I probably forgot.
|
||||
|
|
45
brightness.sh
Normal file
45
brightness.sh
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env bash
|
||||
increment=10
|
||||
backlight_prefix=/sys/class/backlight/intel_backlight/
|
||||
|
||||
echo $1
|
||||
if [[ "$1" = "decrease" ]]; then
|
||||
echo decreasing
|
||||
increment=$(expr -${increment})
|
||||
fi
|
||||
|
||||
cur_brightness=$(cat ${backlight_prefix}brightness)
|
||||
max_brightness=$(cat ${backlight_prefix}max_brightness)
|
||||
|
||||
new_brightness=$(expr ${cur_brightness} + ${increment})
|
||||
|
||||
# Permissions changes on brightness:
|
||||
## change group to sbrl
|
||||
## add g+w
|
||||
# Old command:
|
||||
#gksudo -- bash -c "echo ${new_brightness} >${backlight_prefix}brightness"
|
||||
echo ${new_brightness} >${backlight_prefix}brightness
|
||||
|
||||
####################
|
||||
### Notification ###
|
||||
####################
|
||||
### uncomment the following line to disable the notification
|
||||
#exit
|
||||
# Calculate the percentage
|
||||
new_percent=$(echo "(${new_brightness} / ${max_brightness}) * 100" | bc -l)
|
||||
new_percent=$(printf "%.1f" "${new_percent}")
|
||||
|
||||
echo new_percent: $new_percent
|
||||
|
||||
|
||||
max_bar_length=100
|
||||
bar_length=$(echo "(${new_percent} / 100) * ${max_bar_length}" | bc -l)
|
||||
bar_length=$(printf "%.0f" "${bar_length}")
|
||||
|
||||
n_bar=$(head -c $bar_length < /dev/zero | tr '\0' '=')
|
||||
|
||||
# Kill the previous notification
|
||||
killall notify-osd
|
||||
notify-send "Brightness: ${new_percent}%" "${n_bar} (${new_brightness})"
|
||||
#notify-send "Brightness" "${new_percent}%"
|
||||
|
11
recvdir
Executable file
11
recvdir
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo Recieve an entire directory from the network and save it to the current directory.
|
||||
echo Usage:
|
||||
echo " recvdir ip_address port"
|
||||
exit
|
||||
fi
|
||||
|
||||
nc $1 $2 | tar xzf -
|
||||
|
Loading…
Reference in a new issue