Skip to content

Commit

Permalink
Update to 1.1 - backlight, idle, volume, mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
justbrowsing committed Jul 21, 2014
1 parent 75ab9fb commit f05956b
Show file tree
Hide file tree
Showing 8 changed files with 349 additions and 13 deletions.
18 changes: 12 additions & 6 deletions README.md
Expand Up @@ -8,12 +8,17 @@ JustBrowsing Settings GUI configurator
More information: http://goo.gl/mzbB5G (Tumblr)

Completed:
* New: Set default browser
* New: Detect and set virtual GPU
* New: Set force clean profile
* New: Set homepage
* New: Set keymap
* New: Set locale
* New: Set backlight level
* New: Set idle timeout
* New: Set volume
* New: Set mouse acceleration
* New: Toggle touchpad tapping
* Set default browser
* Detect and set virtual GPU
* Set force clean profile
* Set homepage
* Set keymap
* Set locale
* Set resolution
* Set orientation
* Set timezone
Expand All @@ -24,6 +29,7 @@ Completed:
To-Do:
* Save/load printers
* Save/load networks
* Bug reporting helper
* Set various kernel parameters
* Make generic
* Cleanup code
197 changes: 192 additions & 5 deletions jb-config
@@ -1,7 +1,7 @@
#!/bin/bash
####################
### jb-config ######
version="1.0" ######
version="1.1" ######
### JustBrowsing ###
####################

Expand Down Expand Up @@ -579,14 +579,175 @@ debugOutput() {
echo "USBprint:$USBprint" >> "$tmpFile"
echo "Printer:$Printer" >> "$tmpFile"
echo "Network:$Network" >> "$tmpFile"
echo "Backlight:$Backlight" >> "$tmpFile"
echo "Audio:$Audio" >> "$tmpFile"
echo "Idle:$Idle" >> "$tmpFile"
}

export -f debugOutput

############################################################################################

getLight=$(setjb-backlight current 2>/dev/null)
export getLight

refreshLight() {
getLight=$(setjb-backlight current 2>/dev/null)
[ "$getLight" -ge 1 -a "$getLight" -le 100 ] && echo "$getLight"
}

lightScale() {
echo '<text><label>Screen Backlight (percent)</label></text>
<hscale width-request="300" height-request="50" range-min="1" range-max="100" range-step="1">
<default>'$getLight'</default>
<variable>'$1'</variable>
<input>bash -c "refreshLight"</input>
</hscale>
<hbox homogeneous="true">
<button use-stock="true" label="gtk-apply">
<action>echo "Setting backlight: $'$1'"</action>
<action>setjb-backlight $'$1'</action>
</button>
<button>
<label>Invert</label>
<input file stock="gtk-convert"></input>
<action>echo "Toggle invert colors"</action>
<action>setjb-backlight invert</action>
</button>
<button use-stock="true" label="gtk-revert-to-saved">
<action>echo "Resetting backlight: 100"</action>
<action>setjb-backlight reset</action>
<action function="refresh">'$1'</action>
<action>grabfocus:'$1'</action>
</button>
</hbox>'
}

export -f refreshLight lightScale

############################################################################################

getIdle=$(setjb-idle current 2>/dev/null)
[ "$getIdle" -ge "60" ] 2>/dev/null && getIdle=$((getIdle/60))
export getIdle

refreshIdle() {
getIdle=$(setjb-idle current 2>/dev/null)
[ "$getIdle" -ge "60" ] 2>/dev/null && getIdle=$((getIdle/60))
echo "$getIdle"
}

timeoutScale() {
echo '<text><label>Screen Timeout (minutes)</label></text>
<hscale width-request="300" height-request="50" range-min="0" range-max="60" range-step="1">
<default>'$getIdle'</default>
<variable>'$1'</variable>
<input>bash -c "refreshIdle"</input>
</hscale>
<hbox homogeneous="true">
<button use-stock="true" label="gtk-apply">
<action>echo "Setting timeout: $'$1' minutes"</action>
<action>setjb-idle $'$1' gtk</action>
<action function="refresh">'$1'</action>
<action>grabfocus:'$1'</action>
</button>
<button>
<label>Disable</label>
<input file stock="gtk-stop"></input>
<action>echo "Disabling timeout"</action>
<action>setjb-idle off</action>
<action function="refresh">'$1'</action>
<action>grabfocus:'$1'</action>
</button>
<button use-stock="true" label="gtk-revert-to-saved">
<action>echo "Resetting timeout: 10 minutes"</action>
<action>setjb-idle reset</action>
<action function="refresh">'$1'</action>
<action>grabfocus:'$1'</action>
</button>
</hbox>'
}

export -f refreshIdle timeoutScale

############################################################################################

getVolume=$(setjb-volume current 2>/dev/null)
export getVolume

refreshVolume() {
getVolume=$(setjb-volume current 2>/dev/null)
[ "$getVolume" -ge 1 -a "$getVolume" -le 100 ] && echo "$getVolume"
}

volumeScale() {
echo '<text><label>Sound volume</label></text>
<hscale width-request="300" height-request="50" range-min="0" range-max="400" range-step="1">
<default>'$getVolume'</default>
<variable>'$1'</variable>
<input>bash -c "refreshVolume"</input>
</hscale>
<hbox homogeneous="true">
<button use-stock="true" label="gtk-apply">
<action>echo "Setting volume: $'$1'"</action>
<action>setjb-volume $'$1'</action>
</button>
<button use-stock="true" label="gtk-revert-to-saved">
<action>echo "Resetting volume: 100"</action>
<action>setjb-volume reset</action>
<action function="refresh">'$1'</action>
<action>grabfocus:'$1'</action>
</button>
</hbox>'
}

export -f refreshVolume volumeScale

############################################################################################

getMouse=$(setjb-mouse current 2>/dev/null)
export getMouse

refreshMouse() {
getMouse=$(setjb-mouse current 2>/dev/null)
echo "$getMouse"
}

mouseScale() {
echo '<text><label>Mouse acceleration</label></text>
<hscale width-request="300" height-request="50" range-min="0.01" range-max="4" range-step="0.01">
<default>'$getMouse'</default>
<variable>'$1'</variable>
<input>bash -c "refreshMouse"</input>
</hscale>
<hbox homogeneous="true">
<button use-stock="true" label="gtk-apply">
<action>echo "Setting mouse acceleration: $'$1'"</action>
<action>setjb-mouse $'$1' gtk</action>
</button>
<button>
<label>Click</label>
<input file stock="gtk-select-color"></input>
<action>echo "Toggle mousetap"</action>
<action>setjb-mouse enabletap</action>
</button>
<button use-stock="true" label="gtk-revert-to-saved">
<action>echo "Resetting mouse acceleration: 2/1 4"</action>
<action>setjb-mouse reset</action>
<action function="refresh">'$1'</action>
<action>grabfocus:'$1'</action>
</button>
</hbox>'
}

export -f refreshMouse mouseScale

############################################################################################

MAIN_DIALOG='
<window title="JustBrowsing Config" icon-name="'$icon'" resizable="false" width-request="'$width'">
<vbox>
<notebook tab-labels="Settings|Advanced">
<notebook tab-labels="Settings|Devices|Advanced">
<vbox label="Settings">
<frame>
<hbox>
Expand All @@ -612,7 +773,7 @@ MAIN_DIALOG='
</frame>
</vbox>
<vbox label="Advanced">
<vbox label="Devices">
<frame>
<hbox>
<vbox>
Expand All @@ -629,13 +790,39 @@ MAIN_DIALOG='
</hbox>
</frame>
</vbox>
<vbox label="Advanced">
<frame>
<hbox>
<edit wrap-mode="3">
<input file>/opt/justbrowsing/welcome.txt</input>
</edit>
<vseparator></vseparator>
<vbox>
'"`lightScale Backlight`"'
<hseparator></hseparator>
'"`timeoutScale Idle`"'
<hseparator></hseparator>
'"`mouseScale Cursor`"'
<hseparator></hseparator>
'"`volumeScale Audio`"'
<hseparator></hseparator>
</vbox>
</hbox>
</frame>
</vbox>
</notebook>
<hbox>
<button ok>
<button>
<label>Save</label>
<input file stock="gtk-save"></input>
<action>savejb-config &</action>
<action>exit:Quit</action>
</button>
<button cancel>
<button>
<label>Quit</label>
<input file stock="gtk-quit"></input>
<action>exit:Quit</action>
</button>
<button help>
Expand Down
12 changes: 11 additions & 1 deletion loadjb-config
@@ -1,7 +1,7 @@
#!/bin/bash
####################
### loadconfig #####
version=0.4 ########
version=0.5 ########
### JustBrowsing ###
####################

Expand Down Expand Up @@ -48,6 +48,11 @@ locale=$(PARSE_BOOT locale)
clean=$(PARSE_BOOT clean)
gpu=$(PARSE_BOOT gpu)
url=$(PARSE_BOOT url)
backlight=$(PARSE_BOOT backlight)
idle=$(PARSE_BOOT idle)
volume=$(PARSE_BOOT volume)
mouse=$(PARSE_BOOT mouse)
touchpad=$(PARSE_BOOT touchpad)
default=$(PARSE_BOOT default)
[ "$default" = "chrome" ] && default="google-chrome"

Expand All @@ -60,6 +65,11 @@ OVERRIDE_CONFIG locale
OVERRIDE_CONFIG clean
OVERRIDE_CONFIG gpu
OVERRIDE_CONFIG url
OVERRIDE_CONFIG backlight
OVERRIDE_CONFIG idle
OVERRIDE_CONFIG volume
OVERRIDE_CONFIG mouse
OVERRIDE_CONFIG touchpad
OVERRIDE_CONFIG default

chown -R user:users "$saveDir"
Expand Down
12 changes: 11 additions & 1 deletion savejb-config
@@ -1,7 +1,7 @@
#!/bin/bash
####################
### saveconfig #####
version=0.5 ########
version=0.6 ########
### JustBrowsing ###
####################

Expand Down Expand Up @@ -72,6 +72,11 @@ locale=$(PARSE_CONFIG locale)
clean=$(PARSE_CONFIG clean)
gpu=$(PARSE_CONFIG gpu)
url=$(PARSE_CONFIG url)
backlight=$(PARSE_CONFIG backlight)
idle=$(PARSE_CONFIG idle)
volume=$(PARSE_CONFIG volume)
mouse=$(PARSE_CONFIG mouse)
touchpad=$(PARSE_CONFIG touchpad)
default=$(PARSE_CONFIG default)
[ "$default" = "google-chrome" ] && default="chrome"

Expand All @@ -90,6 +95,11 @@ if [ -b "$probeDevice" ]; then
OVERRIDE_CFG clean
OVERRIDE_CFG gpu
OVERRIDE_CFG url
OVERRIDE_CFG backlight
OVERRIDE_CFG idle
OVERRIDE_CFG volume
OVERRIDE_CFG mouse
OVERRIDE_CFG touchpad
OVERRIDE_CFG default
MAKE_HTML
umount "$mntDir" 2>/dev/null || LOG_STATUS "unable to unmount $mntDir"
Expand Down
34 changes: 34 additions & 0 deletions setjb-backlight
@@ -0,0 +1,34 @@
#!/bin/bash
config="/etc/justbrowsing/data/config"

if [ "$1" -ge 1 -a "$1" -le 100 ] 2>/dev/null; then
backlight="$1"
elif [ -f "$config" ]; then
backlight=$(grep ^backlight "$config" 2>/dev/null | awk -F = '{print $NF}' | awk '{print $NF}')
fi

selectMethod() {
value=$(xbacklight -get 2>/dev/null)
if [ ! -z "$value" ]; then
xbacklight -set "$1"
else
xcalib -c -a
xcalib -co "$1" -a
fi
}

if [ "$1" = "current" ]; then
[ -z "$backlight" ] && backlight="100"
echo "$backlight"
elif [ "$1" = "invert" ]; then
xcalib -invert -a
elif [ "$1" = "reset" ]; then
selectMethod "100"
sed -i '/^backlight/d' "$config"
elif [ ! -z "$backlight" ]; then
selectMethod "$backlight"
sed -i '/^backlight/d' "$config"
echo "backlight = ${backlight}" >> "$config"
fi

export backlight

0 comments on commit f05956b

Please sign in to comment.