The Navigatrix has been updated. The new website can be found at navigatrix.net.




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Turn Laptop Screen On and Off While Machine Stays Running

Joined: 03 Jul 2013, 08:30
Posts: 59
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 HotKeys

Open 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/Off

Assuming 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


Last edited by CapCouillon on 06 Sep 2013, 20:24, edited 1 time in total.

Top
   
 
 Post subject: Re: Turn Laptop Screen On and Off While Machine Stays Runnin

Joined: 04 Nov 2010, 20:51
Posts: 1062
when you run
Code:
xrandr | grep "LVDS"
double check if your using LVDS or LVDS1


Top
   
 
 Post subject: Re: Turn Laptop Screen On and Off While Machine Stays Runnin

Joined: 03 Jul 2013, 08:30
Posts: 59
Assume your test machine uses LVDS1 I dont have such on my box...
What is return from xrandr | grep LVDS (No quotes)?
Started out to use xrandr -q but doesn't show the string I am using as an on/off test

Any other hitches?

Tks for the email


Top
   
 
 Post subject: Re: Turn Laptop Screen On and Off While Machine Stays Runnin

Joined: 04 Nov 2010, 20:51
Posts: 1062
Quote:
wadda@Baboo:~$ xrandr | grep LVDS
LVDS1 connected 1024x600+0+0 (normal left inverted right x axis y axis) 223mm x 125mm
wadda@Baboo:~$
The whole kielbasa can be found with
Code:
wadda@Baboo:~$ xrandr --prop
Screen 0: minimum 320 x 200, current 1024 x 600, maximum 32767 x 32767
LVDS1 connected 1024x600+0+0 (normal left inverted right x axis y axis) 223mm x 125mm
   EDID:
      00ffffffffffff004ca34e5500000000
      0012010380160d780a859599574f8f26
      21505400000001010101010101010101
      010101010101f8160094415856201888
      3600df7d000000190000000f00000000
      00000000001eb4027400000000fe0053
      414d53554e470a2020202020000000fe
      003130314e5430322d4130340a2000ad
   BACKLIGHT: 9 (0x00000009)   range:  (0,9)
   Backlight: 9 (0x00000009)   range:  (0,9)
   scaling mode:   Full aspect
      supported: None         Full         Center       Full aspect
   1024x600       60.0*+
   800x600        60.3     56.2 
   640x480        59.9 
VGA1 disconnected (normal left inverted right x axis y axis)
wadda@Baboo:~$
but is more info than necessary, and maybe not the right info you're looking for.

It's more definative than sleep 2;xset dpms force off as movement from the mouse with turn on the screen again...like on a boat.


Top
   
 
 Post subject: Re: Turn Laptop Screen On and Off While Machine Stays Runnin

Joined: 09 Apr 2014, 15:51
Posts: 45
I'm systematically reading the posts here, and find this one expecially nice. I'd like to be able to just hit the "Windows" key between Fn & Alt, and have the Menu pop up. Is it okay to ask this here, or should I just start a new thread?
I'm a newbie but have reconfigured gpsd in Terminal and system working just fine with Nx. I don't know how to add a directory that is probably needed based on the above post. Best regards, Cleve


Top
   
 
 Post subject: Re: Turn Laptop Screen On and Off While Machine Stays Runnin

Joined: 03 Jul 2013, 08:30
Posts: 59
Which "menu" do you want to pop up Cleve?.... Normal the "windows" key is used in combination with a second key (as in W+m) to initiate an action.
Examples on my machine:
W+t = open terminal window
W+d = toggle desktop
W+f = open file manager
W+x = toggle screen backlight

Some references on Openbox keybinding
http://openbox.org/wiki/Help:Bindings
http://crunchbanglinux.org/wiki/configuring_keybindings
http://melp.nl/2011/01/10-must-have-key-and-mouse-binding-configs-in-openbox/

The last refference includes binding a control key (alt, control, super, etc) plus a mouse button.... Just found that one, and while I haven't tried it, it sounds useful.

Hope this helps, if you want to continue further, should probably start a new "tips and tricks" thread for general key-binding hints to make it easier for others to benifit from the discussion

(the other) David


Top
   
 
 Post subject: Re: Turn Laptop Screen On and Off While Machine Stays Runnin

Joined: 09 Apr 2014, 15:51
Posts: 45
Thank you for the links, I'll try them out and report back in another new thread if I have problems. I'm referring to the bottom left manta screen menu, which is what pops up in the newer mint distros 15-17. I could use the touchscreen, but I know several older folks that have problems using their keyboard and mouse, maybe through conservation of energy, and like to just hit the super key to bring up menu choices. Best regards


Top
   
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Search for:
cron

Credits © 2010 - 2024