summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2023-08-14 18:16:08 -0400
committerrealtradam <[email protected]>2023-08-14 18:16:08 -0400
commit440f126691c42e45b7c85e130c0bec9f6a8ab0df (patch)
tree38f04bf592476ef202eb30b6dbfbcae99ff33081
downloadScripts-master.tar.gz
Scripts-master.zip
-rw-r--r--.bashrc57
-rw-r--r--.gitignore1
-rwxr-xr-xcleanup3
-rwxr-xr-xclip7
-rwxr-xr-xcolors31
-rwxr-xr-xconfig_edit25
-rwxr-xr-xconvertaudioresolve3
-rwxr-xr-xconvertvideoresolve3
-rwxr-xr-xdavinciresolve3
-rwxr-xr-xdownloadYoutube3
-rwxr-xr-xeditingTool4
-rwxr-xr-xemote5
-rwxr-xr-xfastTool3
-rwxr-xr-xforwardsound14
-rwxr-xr-xlogout2
-rwxr-xr-xminecraft1
-rwxr-xr-xmusicPlayer3
-rwxr-xr-xpacins3
-rwxr-xr-xquickTool3
-rwxr-xr-xramdisk4
-rwxr-xr-xrconky3
-rwxr-xr-xs6-howto18
-rwxr-xr-xscreencastDiscord1
-rwxr-xr-xsetWallpaper1
-rwxr-xr-xsettabletrange33
-rwxr-xr-xsims37
-rwxr-xr-xslowTool4
-rwxr-xr-xsnippingTool3
-rwxr-xr-xsonic-pi3
-rwxr-xr-xsplitsound13
-rwxr-xr-xstartupScreen5
-rwxr-xr-xstreamWebcam1
-rwxr-xr-xswl1
-rwxr-xr-xtoggleTrackpad8
-rwxr-xr-xtriscord5
-rwxr-xr-xtwitchdl4
-rwxr-xr-xupdatesystem13
-rwxr-xr-xvideoEditingSplitter12
-rwxr-xr-xweather1
-rwxr-xr-xwiilightmote241
-rwxr-xr-xxbacklightmon17
41 files changed, 572 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
new file mode 100644
index 0000000..50e0641
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,57 @@
+# If not running interactively, don't do anything
+[[ $- != *i* ]] && return
+
+# alias ls='ls --color=auto'
+# PS1='\[\033[01;36m\][\u@\h \A\[\033[01;37m\] \W\[\033[01;36m\]]\$\[\033[00m\] '
+PS1='\[\033[01;36m\][\u@\h \A\[\033[01;37m\] \W\[\033[01;36m\]]\$\[\033[00m\] '
+export EDITOR=nvim
+
+# Add scripts path
+export PATH=$PATH:~/Scripts
+export PATH=$PATH:/opt/eclipse-clp/bin/x86_64_linux
+export PATH=$PATH:/opt/resolve/bin/
+export PATH="$HOME/.cargo/bin:$PATH"
+export PATH="$HOME/.local/bin:$PATH"
+export PATH="$HOME/.yarn/bin:$PATH"
+export PATH="$HOME/.dotnet/tools:$PATH"
+#export PATH=~/Documents/pebble-dev/pebble-sdk-4.5-linux64/bin:$PATH
+#export PATH="$PATH:$HOME/.gem/ruby/3.0.0/bin"
+
+export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
+
+# export emscripten tools path
+export EMSCRIPTEN="/home/tradam/.asdf/shims"
+
+# set qt theme to arc-dark
+export QT_STYLE_OVERRIDE=kvantum
+
+#alias shut='sudo shutdown -hp 0'
+alias la='ls -A'
+alias trsync='rsync -Pr --info=progress2 --no-i-r'
+alias trash='gio trash'
+#alias server='ssh -X 192.168.1.10'
+
+# Ssh-agent (do this for git)
+eval `ssh-agent` > /dev/null 2> /dev/null
+#ssh-add -q /home/tradam/.ssh/malcz #> /dev/null 2> /dev/null
+ssh-add -q /home/tradam/.ssh/realtradam #> /dev/null 2> /dev/null
+
+#source /usr/share/doc/pkgfile/command-not-found.bash
+
+
+# BEGIN_KITTY_SHELL_INTEGRATION
+if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; fi
+# END_KITTY_SHELL_INTEGRATION
+
+# Created by `pipx` on 2022-03-08 22:25:28
+export PATH="$PATH:/home/tradam/.local/bin"
+
+# asdf version manager for programming languages
+. $HOME/.asdf/asdf.sh
+. $HOME/.asdf/completions/asdf.bash
+
+# for dotnet/csharp stuffs
+#. ~/.asdf/plugins/dotnet-core/set-dotnet-home.bash
+
+eval "$(starship init bash)"
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..260157b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+randpass
diff --git a/cleanup b/cleanup
new file mode 100755
index 0000000..9bbdbe0
--- /dev/null
+++ b/cleanup
@@ -0,0 +1,3 @@
+yay -Rns $(yay -Qtdq)
+yay -Sc
+paccache -r
diff --git a/clip b/clip
new file mode 100755
index 0000000..b70e723
--- /dev/null
+++ b/clip
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+if [ -p /dev/stdin ]; then
+ printf "%s" "$(cat)" | xclip -selection clipboard
+else
+ echo "Pipe data to this program to copy it into your clipboard"
+fi
diff --git a/colors b/colors
new file mode 100755
index 0000000..899fb00
--- /dev/null
+++ b/colors
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# Stolen from https://github.com/jaredculp/dotfiles/blob/master/colortest
+
+# Daniel Crisman's ANSI color chart script from
+# The Bash Prompt HOWTO: 6.1. Colours
+# http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
+#
+# This function echoes a bunch of color codes to the
+# terminal to demonstrate what's available. Each
+# line is the color code of one forground color,
+# out of 17 (default + 16 escapes), followed by a
+# test use of that color on all nine background
+# colors (default + 8 escapes).
+
+T='•••' # The text for the color test
+
+echo -e "\n def 40m 41m 42m 43m 44m 45m 46m 47m";
+
+for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
+ '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
+ ' 36m' '1;36m' ' 37m' '1;37m';
+do FG=${FGs// /}
+ echo -en " $FGs \033[$FG $T "
+
+ for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
+ do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
+ done
+ echo;
+done
+echo
diff --git a/config_edit b/config_edit
new file mode 100755
index 0000000..0aa1b03
--- /dev/null
+++ b/config_edit
@@ -0,0 +1,25 @@
+#!/bin/bash
+# simple dmenu config editor for archbang
+# poorly written by Mr Green
+#
+
+# configs you can edit
+choices="mirrorlist\npacman\nlocales\nopenbox-rc\nopenbox-menu"
+
+# dmenu to give prompt and choices
+chosen=$(echo -e "$choices" | dmenu -fn 'Sans Mono-10' -nb '#000000' -nf '#FFFFFF' -sb '#96A79F' -sf '#EEEEEE' -i -p "Select config file to edit..." )
+
+# terminal command
+comm="lxterminal -e nano"
+
+opath="~/.config/openbox"
+
+case "$chosen" in
+ mirrorlist) sudo ${comm} /etc/pacman.d/mirrorlist ;;
+ pacman) sudo ${comm} /etc/pacman.conf ;;
+ locales) sudo ${comm} /etc/locale.gen;;
+ openbox-rc) ${comm} ${opath}/rc.xml ;;
+ openbox-menu) ${comm} ${opath}/menu.xml ;;
+esac
+
+
diff --git a/convertaudioresolve b/convertaudioresolve
new file mode 100755
index 0000000..fa08204
--- /dev/null
+++ b/convertaudioresolve
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+ffmpeg -i "$1" -acodec pcm_s16le "$2"
diff --git a/convertvideoresolve b/convertvideoresolve
new file mode 100755
index 0000000..44780f4
--- /dev/null
+++ b/convertvideoresolve
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+ffmpeg -i "$1" -vcodec dnxhd -acodec pcm_s16le -s 1280x720 -r 30000/1001 -b:v 60M "$2"
diff --git a/davinciresolve b/davinciresolve
new file mode 100755
index 0000000..4b5ada6
--- /dev/null
+++ b/davinciresolve
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+swl /opt/resolve/bin/resolve
diff --git a/downloadYoutube b/downloadYoutube
new file mode 100755
index 0000000..a1a0bdc
--- /dev/null
+++ b/downloadYoutube
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+youtube-dl -f bestvideo+bestaudio "$1"
diff --git a/editingTool b/editingTool
new file mode 100755
index 0000000..b1a2a99
--- /dev/null
+++ b/editingTool
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+TMP=$(date +%F-%T)
+maim -s | convert - ~/Pictures/Screenshots/$TMP.png && gimp ~/Pictures/Screenshots/$TMP.png
diff --git a/emote b/emote
new file mode 100755
index 0000000..57e999a
--- /dev/null
+++ b/emote
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+
+img="$(ls $1 | dmenu -m 0 -sb '#316299' -nb '#252732')"
+(cd $1; xclip -selection clipboard -t ~/thinkcenter/emotes/${img##*.} $img)
diff --git a/fastTool b/fastTool
new file mode 100755
index 0000000..98d30a6
--- /dev/null
+++ b/fastTool
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+maim | tee >(convert - ~/Pictures/IFSE/IFSE_$(date +%F-%H_%M_%S).png) | xclip -selection clipboard -t image/png
diff --git a/forwardsound b/forwardsound
new file mode 100755
index 0000000..a23acfb
--- /dev/null
+++ b/forwardsound
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+#SPEAKERS="alsa_output.pci-0000_00_1f.3.analog-stereo"
+SPEAKERS="bluez_sink.2C_41_A1_C8_53_63.a2dp_sink"
+MICROPHONE="alsa_input.usb-BLUE_MICROPHONE_Blue_Snowball_AYM_2018_05_30_16341-00.mono-fallback"
+
+# virtual1=fSource gets the audio source your want to forward and listen to(browser, media player, etc)
+# result gets fSource + mic and it gets sent to your voip software(discord, etc)
+pactl load-module module-null-sink sink_name=fSource sink_properties=device.description="fSource"
+pactl load-module module-null-sink sink_name=result sink_properties=device.description="result"
+
+pactl load-module module-loopback source=fSource.monitor sink=$SPEAKERS
+pactl load-module module-loopback source=fSource.monitor sink=result
+pactl load-module module-loopback source=$MICROPHONE sink=result
diff --git a/logout b/logout
new file mode 100755
index 0000000..45bbc99
--- /dev/null
+++ b/logout
@@ -0,0 +1,2 @@
+#!/bin/bash
+loginctl terminate-session 1
diff --git a/minecraft b/minecraft
new file mode 100755
index 0000000..8ac5045
--- /dev/null
+++ b/minecraft
@@ -0,0 +1 @@
+swl mangohud --dlsym minecraft-launcher
diff --git a/musicPlayer b/musicPlayer
new file mode 100755
index 0000000..06ebd31
--- /dev/null
+++ b/musicPlayer
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mpv --geometry=400x400 -shuffle -loop-playlist --title="Moosic" --osc=no "$@"
diff --git a/pacins b/pacins
new file mode 100755
index 0000000..17e70d1
--- /dev/null
+++ b/pacins
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+awk '/%NAME%/{getline;PKG=$1} /%INSTALLDATE%/{getline;IDATE=strftime("%Y-%m-%d %H:%M",$1);print IDATE" "PKG}' /var/lib/pacman/local/*/desc | sort -r
diff --git a/quickTool b/quickTool
new file mode 100755
index 0000000..58712a7
--- /dev/null
+++ b/quickTool
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+maim -i $(xdotool getactivewindow) | tee >(convert - ~/Pictures/Screenshots/$(date +%F-%T).png) | xclip -selection clipboard -t image/png
diff --git a/ramdisk b/ramdisk
new file mode 100755
index 0000000..8e25d50
--- /dev/null
+++ b/ramdisk
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+mkdir /tmp/$1
+sudo mount -t tmpfs -o nodev,nosuid,noexec,nodiratime,size=$2 none /tmp/$1
diff --git a/rconky b/rconky
new file mode 100755
index 0000000..997b523
--- /dev/null
+++ b/rconky
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+killall conky && conky
diff --git a/s6-howto b/s6-howto
new file mode 100755
index 0000000..ebf5d7f
--- /dev/null
+++ b/s6-howto
@@ -0,0 +1,18 @@
+echo '
+Services:
+List all active services s6-rc -a list
+List all services that depend on foo s6-rc-db -d all-dependencies foo
+Stop a service/bundle s6-rc -d change service_name
+Start a service/bundle s6-rc -u change service_name
+List all active services s6-rc -a list
+List all services/bundles in the database s6-rc-db list all
+
+Bundles:
+To create a bundle s6-rc-bundle add <bundle> <service1> <service2> <service3>
+To delete a bundle s6-rc-bundle delete <bundle>
+To remove something from an existing bundle s6-rc-bundle-update delete <bundle> <service>
+To add something to an existing bundle s6-rc-bundle-update add <bundle> <service>
+
+To edit who runs something --> /etc/s6/sv
+'
+
diff --git a/screencastDiscord b/screencastDiscord
new file mode 100755
index 0000000..edad934
--- /dev/null
+++ b/screencastDiscord
@@ -0,0 +1 @@
+ffmpeg -f x11grab -s 1920x1080 -r 30 -i :0.0+1920,851 -b:v 2500 -vcodec libx264 -crf 23 -preset ultrafast -s 1920x1080 -f flv - | mpv -
diff --git a/setWallpaper b/setWallpaper
new file mode 100755
index 0000000..3172694
--- /dev/null
+++ b/setWallpaper
@@ -0,0 +1 @@
+(cd /home/tradam/Pictures/Wallpapers/scripts/; ./setWallpaper.sh)
diff --git a/settabletrange b/settabletrange
new file mode 100755
index 0000000..80c9af3
--- /dev/null
+++ b/settabletrange
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+device="UGTABLET 10 inch PenTablet Pen (0)"
+
+#total_width=5280.0
+#total_height=2820.0
+
+#touch_area_width=1920.0
+#touch_area_height=1200.0
+#touch_area_x_offset=1920.0
+#touch_area_y_offset=791.0
+
+total_width=3520 #3640.0
+total_height=1080 #2560.0
+
+touch_area_width=1600 #1080.0
+touch_area_height=900 #1728.0
+touch_area_x_offset=0 #3640.0
+touch_area_y_offset=0 #832.0
+
+echo $touch_area_width
+
+C0=$(bc -l <<< $touch_area_width/$total_width)
+C2=$(bc -l <<< $touch_area_height/$total_height)
+C1=$(bc -l <<< $touch_area_x_offset/$total_width)
+C3=$(bc -l <<< $touch_area_y_offset/$total_height)
+
+echo Device: $device
+MATRIX="$C0 0 $C1 0 $C2 $C3 0 0 1" #normal
+#MATRIX="0 -$C0 $C1 $C2 0 $C3 0 0 1" #rotate
+echo Calculated Matrix: $MATRIX
+
+xinput set-prop "$device" --type=float "Coordinate Transformation Matrix" $MATRIX
diff --git a/sims3 b/sims3
new file mode 100755
index 0000000..bad7419
--- /dev/null
+++ b/sims3
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+mkdir /tmp/sims3
+sudo mount -t tmpfs -o nodev,nosuid,noexec,nodiratime,size=1G none /tmp/sims3
+mkdir /tmp/sims3/{Thumbnails,WorldCaches}
+WINEPREFIX=~/.local/share/wineprefixes/sims3/ wine "/home/tradam/.local/share/wineprefixes/sims3/drive_c/Program Files/Electronic Arts/The Sims 3/Game/Bin/TS3W.exe"
+sudo umount /tmp/sims3
diff --git a/slowTool b/slowTool
new file mode 100755
index 0000000..937f50d
--- /dev/null
+++ b/slowTool
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+TMP=$(date +%F-%T)
+maim | convert - ~/Pictures/Screenshots/$TMP.png && gimp ~/Pictures/Screenshots/$TMP.png
diff --git a/snippingTool b/snippingTool
new file mode 100755
index 0000000..d18ce08
--- /dev/null
+++ b/snippingTool
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+maim -us | tee >(convert - ~/Pictures/Screenshots/$(date +%F-%T).png) | xclip -selection clipboard -t image/png
diff --git a/sonic-pi b/sonic-pi
new file mode 100755
index 0000000..2a61cdb
--- /dev/null
+++ b/sonic-pi
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+pw-jack ~/sonic-pi/app/build/gui/qt/sonic-pi
diff --git a/splitsound b/splitsound
new file mode 100755
index 0000000..e5ce396
--- /dev/null
+++ b/splitsound
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+SPEAKERS="bluez_sink.2C_41_A1_C8_53_63.a2dp_sink"
+
+# Create the null sinks
+# setInPlayback gets your audio source (mplayer ...) only
+# setInRecording gets setInPlayback + micro
+pactl load-module module-null-sink sink_name=OBSGame sink_properties=device.description="OBSGame"
+pactl load-module module-null-sink sink_name=OBSChat sink_properties=device.description="OBSChat"
+pactl load-module module-null-sink sink_name=OBSMusic sink_properties=device.description="OBSMusic"
+pactl load-module module-loopback source=OBSGame.monitor sink=$SPEAKERS
+pactl load-module module-loopback source=OBSChat.monitor sink=$SPEAKERS
+pactl load-module module-loopback source=OBSMusic.monitor sink=$SPEAKERS
diff --git a/startupScreen b/startupScreen
new file mode 100755
index 0000000..c753205
--- /dev/null
+++ b/startupScreen
@@ -0,0 +1,5 @@
+#!/bin/bash
+sudo modprobe evdi udl
+sudo swl /usr/lib/displaylink/DisplayLinkManager
+sleep 2
+/home/tradam/.screenlayout/2WideMonitor.sh
diff --git a/streamWebcam b/streamWebcam
new file mode 100755
index 0000000..a27c3a2
--- /dev/null
+++ b/streamWebcam
@@ -0,0 +1 @@
+mpv "av://v4l2:/dev/$1" --profile=low-latency --untimed -osc=no -title Webcam
diff --git a/swl b/swl
new file mode 100755
index 0000000..526cb8f
--- /dev/null
+++ b/swl
@@ -0,0 +1 @@
+nohup "$@" > /dev/null 2> /dev/null &
diff --git a/toggleTrackpad b/toggleTrackpad
new file mode 100755
index 0000000..36e8f59
--- /dev/null
+++ b/toggleTrackpad
@@ -0,0 +1,8 @@
+#!/bin/bash
+TRACKPADSTATE=$(xinput --list-props "SynPS/2 Synaptics TouchPad" | head -2 | tail -1 | grep '.$' -o)
+if [[ "$TRACKPADSTATE" == "0" ]]
+then
+ xinput enable "SynPS/2 Synaptics TouchPad"
+else
+ xinput disable "SynPS/2 Synaptics TouchPad"
+fi
diff --git a/triscord b/triscord
new file mode 100755
index 0000000..e45dce5
--- /dev/null
+++ b/triscord
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+until /usr/bin/discord; do
+ notify-send -c 'im.error' -i /home/tradam/.scripts/discordCrashHandler/Discord-Logo-Color.png 'Crash Error' 'Discord has crashed. Start this garbage up again' && paplay /home/tradam/.scripts/discordCrashHandler/disconnect.ogg
+done
diff --git a/twitchdl b/twitchdl
new file mode 100755
index 0000000..3fc0fa1
--- /dev/null
+++ b/twitchdl
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+streamlink -o $1 $2 audio && ffmpeg -i $1 $1.mp3 && rm $1 && rsync -P $1.mp3 [email protected]:Downloads/$1.mp3 && rm $1.mp3
+
diff --git a/updatesystem b/updatesystem
new file mode 100755
index 0000000..fb76dd4
--- /dev/null
+++ b/updatesystem
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+#if [ $EUID != 0 ]; then
+# sudo "$0" "$@"
+# exit $?
+#fi
+
+#sudo -u tradam
+yay -Pw
+#sudo -u tradam
+yay -Syu --devel --upgrademenu
+
+sudo pacdiff
diff --git a/videoEditingSplitter b/videoEditingSplitter
new file mode 100755
index 0000000..808ca62
--- /dev/null
+++ b/videoEditingSplitter
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+mkdir $1
+
+ffmpeg -i $1.mkv \
+-map 0:v -c copy $1/video_h264.mp4 \
+-map 0:a:0 -c copy $1/all.aac \
+-map 0:a:1 -c copy $1/ch1.aac \
+-map 0:a:2 -c copy $1/ch2.aac \
+-map 0:a:1 -c copy $1/ch3.aac \
+-map 0:a:2 -c copy $1/ch4.aac \
+
diff --git a/weather b/weather
new file mode 100755
index 0000000..67a2d1f
--- /dev/null
+++ b/weather
@@ -0,0 +1 @@
+curl wttr.in
diff --git a/wiilightmote b/wiilightmote
new file mode 100755
index 0000000..0b78212
--- /dev/null
+++ b/wiilightmote
@@ -0,0 +1,241 @@
+#!/usr/bin/env ruby
+require 'hue'
+require 'cwiid'
+
+bridge = Hue.application
+
+colour = Hue::Colors::ColorTemperature.new(6500)
+
+
+up = []
+
+i = 0
+
+for light in bridge.lights
+ up << [bridge.bulbs[i], light]
+ i += 1
+end
+
+right = up
+left = up
+down = up
+
+state = up
+
+
+for light in up
+ puts light[1]
+ puts light[1][1]["type"]
+end
+
+for light in up
+ puts light[0]
+ light[0].alert = 'select'
+end
+
+
+for light in bridge.lights
+ puts light[1]["type"]
+ if light[1]["type"] == "Extended color light"
+ puts "detected"
+ end
+end
+
+=begin
+
+dpad
+up is select all lights(and turn them on)
+right, left, down are 3 unique groups(and turn them on)
+down will always turn on at lowest brightness
+flash briefly when selecting a group
+
+hold home and 1 to cycle through all and press dpad to assign (up to assign to none of 3 unique groups)
+flash while on selected bulb
+
+A is regular light
+B is coloured light(if availible)
+
+=end
+
+loop do
+ begin
+ puts "Searching for wiimote(press 1 + 2)"
+ wiimote = WiiMote.new
+ puts "Wiimote Connected"
+ wiimote.rpt_mode = wiimote.rpt_mode = WiiMote::RPT_BTN | WiiMote::RPT_ACC
+
+ wiimote.led = 9
+ wiimote.get_state
+
+
+ begin
+ wiimote.get_state
+
+ if ( wiimote.buttons & WiiMote::BTN_HOME ) != 0
+ for bulb in state
+ if bulb[0].on?
+ bulb[0].off
+ else
+ bulb[0].on
+ end
+ end
+ sleep(0.5)
+ end
+
+ if ( wiimote.buttons & WiiMote::BTN_A ) != 0
+ for bulb in state
+ if bulb[0].on?
+ colour = Hue::Colors::ColorTemperature.new(((([[wiimote.acc[1].to_f,150.0].min,100.0].max - 100.0)/50.0) * 4500) + 2000)
+ bulb[0].color = colour
+ end
+ end
+ end
+
+ if ( wiimote.buttons & WiiMote::BTN_B ) != 0
+ for bulb in state
+ if bulb[0].on? && (bulb[1][1]["type"] == "Extended color light")
+ colour = Hue::Colors::HueSaturation.new((([[wiimote.acc[1].to_f,150.0].min,100.0].max - 100.0)/50.0) * 65535, 255)
+ bulb[0].color = colour
+ end
+ end
+ end
+
+ if ( wiimote.buttons & WiiMote::BTN_PLUS ) != 0
+ for bulb in state
+ if bulb[0].on?
+ if ( bulb[0].brightness + 15 ) < 255
+ bulb[0].brightness += 15
+ else
+ bulb[0].brightness = 255
+ end
+ end
+ end
+ end
+
+ if ( wiimote.buttons & WiiMote::BTN_MINUS ) != 0
+ for bulb in state
+ if bulb[0].on?
+ if ( bulb[0].brightness - 15 ) > 1
+ bulb[0].brightness -= 15
+ else
+ bulb[0].brightness = 1
+ end
+ end
+ end
+ end
+
+ if ( wiimote.buttons & WiiMote::BTN_UP ) != 0
+ state = up
+ for bulb in state
+ puts 'a'
+ puts bulb[0]
+ bulb[0].on
+ bulb[0].alert = 'select'
+ end
+ end
+ if ( wiimote.buttons & WiiMote::BTN_RIGHT ) != 0
+ if (( wiimote.buttons & WiiMote::BTN_1 ) != 0)
+ wiimote.led = 6
+ right = []
+ for bulb in up
+ bulb[0].alert = 'lselect'
+ input = 'none'
+ while input == 'none'
+ wiimote.get_state
+ if (( wiimote.buttons & WiiMote::BTN_A ) != 0)
+ right << bulb
+ bulb[0].alert = 'none'
+ input = 'end'
+ sleep(0.5)
+ elsif (( wiimote.buttons & WiiMote::BTN_B ) != 0)
+ bulb[0].alert = 'none'
+ input = 'end'
+ sleep(0.5)
+ end
+ sleep(0.001)
+ end
+ end
+ state = right
+ wiimote.led = 9
+ else
+ state = right
+ for bulb in state
+ bulb[0].on
+ bulb[0].alert = 'select'
+ end
+ end
+ end
+ if ( wiimote.buttons & WiiMote::BTN_DOWN ) != 0
+ if (( wiimote.buttons & WiiMote::BTN_1 ) != 0)
+ wiimote.led = 6
+ down = []
+ for bulb in up
+ bulb[0].alert = 'lselect'
+ input = 'none'
+ while input == 'none'
+ wiimote.get_state
+ if (( wiimote.buttons & WiiMote::BTN_A ) != 0)
+ down << bulb
+ bulb[0].alert = 'none'
+ input = 'end'
+ sleep(0.5)
+ elsif (( wiimote.buttons & WiiMote::BTN_B ) != 0)
+ bulb[0].alert = 'none'
+ input = 'end'
+ sleep(0.5)
+ end
+ sleep(0.001)
+ end
+ end
+ state = down
+ wiimote.led = 9
+ else
+ state = down
+ for bulb in state
+ bulb[0].on
+ bulb[0].brightness = 1
+ end
+ end
+ end
+ if ( wiimote.buttons & WiiMote::BTN_LEFT ) != 0
+ if (( wiimote.buttons & WiiMote::BTN_1 ) != 0)
+ wiimote.led = 6
+ left = []
+ for bulb in up
+ bulb[0].alert = 'lselect'
+ input = 'none'
+ while input == 'none'
+ wiimote.get_state
+ if (( wiimote.buttons & WiiMote::BTN_A ) != 0)
+ left << bulb
+ bulb[0].alert = 'none'
+ input = 'end'
+ sleep(0.5)
+ elsif (( wiimote.buttons & WiiMote::BTN_B ) != 0)
+ bulb[0].alert = 'none'
+ input = 'end'
+ sleep(0.5)
+ end
+ sleep(0.001)
+ end
+ end
+ state = left
+ wiimote.led = 9
+ else
+ state = left
+ for bulb in state
+ bulb[0].on
+ bulb[0].alert = 'select'
+ end
+ end
+ end
+ sleep(0.001)
+ end until ( wiimote.buttons & WiiMote::BTN_2 ) != 0
+ wiimote.close
+ puts "Wiimote Disconnected"
+ rescue RuntimeError => e
+ puts e.message
+ puts "Trying to connect again..."
+ end
+end
+
diff --git a/xbacklightmon b/xbacklightmon
new file mode 100755
index 0000000..5120fbf
--- /dev/null
+++ b/xbacklightmon
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+path=/sys/class/backlight/acpi_video0
+
+luminance() {
+ read -r level < "$path"/actual_brightness
+ factor=$((100 / max))
+ printf '%d\n' "$((level * factor))"
+}
+
+read -r max < "$path"/max_brightness
+
+xbacklight -set "$(luminance)"
+
+inotifywait -me modify --format '' "$path"/actual_brightness | while read; do
+xbacklight -set "$(luminance)"
+done