Need to be able to turn off my laptop screen with a one key toggle. This does not involve the use of an external VGA or other monitor. Running openbox on Navigatrix (Debian/Ubuntu based "Boat-Centric distro) Machine is an older Dell Studio 1535.
Due to power usage (onboard a vessel) I need to be able to kill the built in display while leaving the box running. First solution was to keybind a shell command to enable or disable the display Eg: Super-N runs the command 'xrandr --output LVDS --off' killing thto e display. Super-M runs the command 'xrandr --output LVDS --auto restoring the display to its "prefered" settings.
Works well enough but being bone-headed I want to be able to toggle on/off with one key. Figured a bash script would work as I found numerous examples to enable/disable LVDS when using external monitors. Problem is I have been unable to bend any of them to my will, probably since I just know enough to be dangerous. Hence this great wall of text hoping someone will take pity and put me out of my misery. Short (as I can make it) description of my method of attack, and where I fell on my butt.
1. Looked at output of shell command "
xrandr | grep "LVDS" with LVDS output enabled and disabled. These are the results:
Code:
LVDS ENABLED
david@wilson:~$ xrandr | grep "LVDS"
LVDS connected 1280x800+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
david@wilson:~$
LVDS DISABLED
david@wilson:~$ xrandr | grep "LVDS"
LVDS connected (normal left inverted right x axis y axis)
david@wilson:~$
2. Looked pretty simple to me.. The string "1280x800+0+0" is missing when LVDS is disabled. Hence the script logic is:
Code:
Variable = "1280x800+0+0"
Run the shell command "xrandr | grep "LVDS"
If the Variable is not present (we know LVDS is disabled)
Then run the command "xrandr --output LVDS --auto"
Else (variable is present) run command "xrandr --output LVDS --off"
Finished
Keybind the script and it should turn the screen on if its off, and off if its on with one key.... Problem is I lost my way amongst the operators and syntax and , and, and, just to much to take in in one day, One attempt that did not work.
Code:
#!/bin/bash
INTERNAL_OUTPUT="1280x800+0+0"
xrandr | grep "LVDS"
if [[ -z $INTERNAL_OUTPUT ]]
then
xrandr --output LVDS --auto
else
xrandr --output LVDS --off
fi
All this script will do is output "xrandr | grep "LVDS"
End of whine... Time for a rum and a nap whilest I await rescue.
TIA