Skip to content

Commit

Permalink
add dumb scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Jessica Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Jun 7, 2015
1 parent cac9240 commit 07816fc
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bin/browser-exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

# browser-exec
# This script opens a hyperlink in the browser that is
# currently being run in a container.
# It first checks if chrome is running then firefox.
#
# TODO: If neither are running it should start chrome container
#
# Usage:
# browser-exec $uri
#

browser_exec(){
# check if chrome container is running
chrome_state=$(docker inspect --format "{{.State.Running}}" chrome 2>/dev/null)
if [[ "$chrome_state" == "true" ]]; then
docker exec -i chrome /usr/bin/google-chrome --user-data-dir=/data "$@" 2>/dev/null
else
# check if firefox container is running
firefox_state=$(docker inspect --format "{{.State.Running}}" firefox 2>/dev/null)
if [[ "$firefox_state" == "true" ]]; then
docker exec -i firefox /usr/bin/firefox "$@" 2>/dev/null
else
echo "[browser_exec]: chrome or firefox is not currently running in a container"
fi
fi
}

browser_exec $@
38 changes: 38 additions & 0 deletions bin/fancy-i3lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

# fancy-i3lock
# Based on the awesome sauce of https://github.com/meskarune/i3lock-fancy
# This just uses imagemagick in a container...
# because reasons...
#
# Dependencies:
# - docker
# - i3lock
# - scrot

# subshell this shiz
(

IMAGE=/tmp/i3lock.png

# All options are here: http://www.imagemagick.org/Usage/blur/#blur_args
# BLURTYPE="0x5" # 7.52s
# BLURTYPE="0x2" # 4.39s
BLURTYPE="5x3" # 3.80s
# BLURTYPE="2x8" # 2.90s
# BLURTYPE="2x3" # 2.92s

scrot $IMAGE

docker run --rm \
-v $IMAGE:$IMAGE \
-v $HOME/Pictures/lock.png:/root/lock.png \
jess/imagemagick \
sh -c "convert $IMAGE -brightness-contrast -30x10 -level 0%,100%,0.6 -blur $BLURTYPE -gravity center - | composite -gravity center /root/lock.png - $IMAGE"

i3lock -i $IMAGE

rm $IMAGE

)
59 changes: 59 additions & 0 deletions bin/keyboard-backlight
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
set -e

# keyboard-backlight
# For when you are running leeenux on a Mac and it needs some help
#
# Usage:
# keyboard-backlight {up,down,total,off}
#

BACKLIGHT=$(cat /sys/class/leds/smc::kbd_backlight/brightness)
INCREMENT=15

if [ $UID -ne 0 ]; then
echo "Please run this program as superuser"
exit 1
fi

SET_VALUE=0
case $1 in

up)
TOTAL=`expr $BACKLIGHT + $INCREMENT`
if [ $TOTAL -gt "255" ]; then
exit 1
fi
SET_VALUE=1
;;
down)
TOTAL=`expr $BACKLIGHT - $INCREMENT`
if [ $TOTAL -lt "0" ]; then
exit 1
fi
SET_VALUE=1
;;
total)
TEMP_VALUE=$BACKLIGHT
while [ $TEMP_VALUE -lt "255" ]; do
TEMP_VALUE=`expr $TEMP_VALUE + 1`
if [ $TEMP_VALUE -gt "255" ]; then TEMP_VALUE=255; fi
echo $TEMP_VALUE > /sys/class/leds/smc::kbd_backlight/brightness
done
;;
off)
TEMP_VALUE=$BACKLIGHT
while [ $TEMP_VALUE -gt "0" ]; do
TEMP_VALUE=`expr $TEMP_VALUE - 1`
if [ $TEMP_VALUE -lt "0" ]; then TEMP_VALUE=0; fi
echo $TEMP_VALUE > /sys/class/leds/smc::kbd_backlight/brightness
done
;;
*)
echo "Use: keyboard-backlight up|down|total|off"
;;
esac

if [ $SET_VALUE -eq "1" ]; then
echo $TOTAL > /sys/class/leds/smc::kbd_backlight/brightness
fi
73 changes: 73 additions & 0 deletions bin/screen-backlight
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
set -e

# screen-backlight
# For when you are running leeenux on a Mac and it needs some help
#
# Usage:
# screen-backlight {up,down,total,off}
#


if [ $UID -ne 0 ]; then
echo "Please run this program as superuser"
exit 1
fi

BLDIR=/sys/class/backlight/acpi_video0
GMDIR=/sys/class/backlight/gmux_backlight
if [[ ! -d $BLDIR ]]; then
if [[ -d $GMDIR ]]; then
BLDIR=$GMDIR
else
echo "Check what directory your backlight is stored in /sys/class/backlight/"
exit 1
fi
fi

BLFILE="$BLDIR/brightness"
BACKLIGHT=$(cat $BLFILE)
INCREMENT=15
SET_VALUE=0
MAX=$(cat "$BLDIR/max_brightness")

case $1 in

up)
TOTAL=`expr $BACKLIGHT + $INCREMENT`
if [ $TOTAL -gt "$MAX" ]; then
exit 1
fi
SET_VALUE=1
;;
down)
TOTAL=`expr $BACKLIGHT - $INCREMENT`
if [ $TOTAL -lt "0" ]; then
exit 1
fi
SET_VALUE=1
;;
total)
TEMP_VALUE=$BACKLIGHT
while [ $TEMP_VALUE -lt "$MAX" ]; do
TEMP_VALUE=`expr $TEMP_VALUE + 1`
if [ $TEMP_VALUE -gt "$MAX" ]; then TEMP_VALUE=$MAX; fi
echo $TEMP_VALUE > $BLFILE
done
;;
off)
TEMP_VALUE=$BACKLIGHT
while [ $TEMP_VALUE -gt "0" ]; do
TEMP_VALUE=`expr $TEMP_VALUE - 1`
if [ $TEMP_VALUE -lt "0" ]; then TEMP_VALUE=0; fi
echo $TEMP_VALUE > $BLFILE
done
;;
*)
echo "Use: screen-backlight up|down|total|off"
;;
esac

if [ $SET_VALUE -eq "1" ]; then
echo $TOTAL > $BLFILE
fi

0 comments on commit 07816fc

Please sign in to comment.