A couple of tricks I use on my laptop (Dell Studio 1535) to turn off tne screen while leaving the computer running. Why would I want to do that? One, it saves power, and also their are times I don't like the screen shining in my eyes while I am in the pilot berth. Method 1 "should" work for any laptop running Nx. Method 2 is somewhat specific to my machine but should work with yours with a bit of modification. In either case if you disable the screen, and cannot re-enable it... Don't panic. A reboot will return "xrandr" (which we use to control the screen) to its default state.
Method 1 - Two HotKeysOpen the file /.config/openbox/navigatrix-rc.xml (located in your "home" directory" ) with your favorite text editor. Scroll down till you find the end of the <keyboard> section. It will look like this.
Code:
<keybind key="C-W-Down">
<action name="Execute">
<startupnotify>
<enabled>true</enabled>
<name>Screen Down</name>
</startupnotify>
<command>xrandr -o inverted</command>
</action>
</keybind>
</keyboard>
We will now insert a new "keybind" to send actions to "xrandr". Take a look through the list of existing keybinds so you don't duplicate. In my example we use W-M and W-N
That is holding down the "Super" (Windows) key and the M or N key at the same time. You can use any unused combination you like A = alt C = ctl S = shft etc.
Using my combination of W-M and W-N insert the following into navigatrix-rc.xml
Code:
<!-- Keybinds to blank/unblank screen -->
<keybind key="W-M">
<action name="Execute">
<command>xrandr --output LVDS --off </command>
</action>
</keybind>
<keybind key="W-N">
<action name="Execute">
<command>xrandr --output LVDS --auto </command>
</action>
</keybind>
<!-- End Keybinds to blank/unblank screen>
just before the </keyboard> entry so it looks like this
Code:
<keybind key="C-W-Down">
<action name="Execute">
<startupnotify>
<enabled>true</enabled>
<name>Screen Down</name>
</startupnotify>
<command>xrandr -o inverted</command>
</action>
</keybind>
<!-- Keybinds to blank/unblank screen -->
<keybind key="W-M">
<action name="Execute">
<command>xrandr --output LVDS --off </command>
</action>
</keybind>
<keybind key="W-N">
<action name="Execute">
<command>xrandr --output LVDS --auto </command>
</action>
</keybind>
<!-- End Keybinds to blank/unblank screen>
</keyboard>
Save the file.... Log out of your session and log back in.
Give it a try!What we have done is told openbox "When I press the W-M combination, tell xrandr to turn off the local lcd display (LVDS) and when I press the W-N combination turn LVDS on to the prefered resolution.
Method 2 - Single Hotkey Toggles Sreen On/OffAssuming Method 1 worked and you're still with me, this is a way to have a single hotkey toggle the screen on/off. Useful if (like me) you are too lazy to remember all the available keybind combinations available. While this method is just as simple as Method 1, you might need to jigger the script a bit to fit your machine. Here is how we check...
In the terminal window, enter the following
Code:
xrandr | grep LVDS
You will end up with an output that looks something like this
Code:
LVDS connected 1280x800+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
If the string "1280x800+0+0" is the same in your output we are good to go.
if it is something else (eg LVDS1 1440x800+0+0 or maybe 800x600+0+0 etc) we will need to change it in the "Stoggle" script below.. Easy to do, but this string represents the "prefered" resolution for your laptop screen, and what we use test whether it is on or off.
Onward to the script...
Open your file manager and create a new sub directory called .scripts (The dot just means it is usually hidden. Personal preference for my scripts but if you name it something else you will have to modify my example keybinding to reflect that) Copy the script below
Code:
#!/bin/bash
INTERNAL_OUTPUT="LVDS.*1280x800+0+0"
xrandr | grep -q "$INTERNAL_OUTPUT" && xrandr --output LVDS --off \
|| xrandr --output LVDS --auto
and save it in your newly created directory as "stoggle' (no quotes, no caps). Right click on the new file and select " Properties > Permissions ". Set Execute: to Only Owner and Group.
If the string we found via xrandr | grep "LVDS" is different than in the Stoggle script, open stoggle in a text editor and change it. For example if your output was 1440x800+0+0 the change would be from:
INTERNAL_OUTPUT="LVDS.*1280x800+0+0"
to
INTERNAL_OUTPUT="LVDS.*1440x800+0+0"
(You also might see LVDS1 instead of LVDS, if so change that as well)
Don't change anything else, and check to make sure. Save your changes.
Thats it for the script.. Now for a new keybinding. As before you can make it anything you care to, in this example it is for W-X. Copy the following into navigatrix-rc.xml just like in Method 1
Code:
<!-- Keybind to Screen-Toggle scripts -->
<keybind key="W-X">
<action name="Execute">
<command>~/.scripts/stoggle</command>
</action>
</keybind>
After saving file, log out.. log in.. and
Give it a try!If its working, you can remove the Method 1 keybindings if you want, or not.. I have added (or changed) several keybindings in navigatrix-rc.xml to open a terminal window, file manager, or other program without having to use the mouse. Same principles as above.
Hope someone finds this of use. Long post but tried to include all the steps for those of us who are not quite so tech-savvy.
Cap' Couillon