Announcement

Collapse
No announcement yet.

quick monitor off/on

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • vsreeser
    replied
    Kubicle, I see now. Looked it over again.

    Wheel inventor, looks better than the static switch icon I had

    Leave a comment:


  • Wheel Inventor
    replied
    On / Off Switch

    ...Now I'll just make it into a shortcut, find a light switch icon (have to figure out how to assign an icon to a script) and throw it onto the panel...


    Alternative - source: http://kde-apps.org/content/show.php...content=116323
    On/Off Switch 0.2 Plasmoid Binary

    Description:
    On/Off Switch is a simple plasmoid that executes commands when the switch is toggled...




    PPA binary search: https://launchpad.net/ubuntu/+ppas?n...-on-off-switch

    Leave a comment:


  • kubicle
    replied
    Originally posted by vsreeser View Post
    That works. Now I'll just make it into a shortcut, find a light switch icon (have to figure out how to assign an icon to a script) and throw it onto the panel.
    You can create a .desktop file your script (and put it in your menu) with kmenuedit. You can set the icon (and optionally a keyboard shortcut for even faster toggling), you can then add the icon to the panel from the menu.

    Originally posted by vsreeser View Post
    Looked everything over and I'm not sure how you figured that out. Would like to know as I might be able to apply to something in the future. If you would be so kind. Might help someone else too
    If you look at your xrandr output when the monitor is on/off:
    On: DVI-I-3 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 598mm x 336mm
    Off: DVI-I-3 connected (normal left inverted right x axis y axis)
    And we needed a grep match for only the "On" Status. "DVI-I-3 connected 1920" will match when the monitor is on, but not when it's off.

    Leave a comment:


  • vsreeser
    replied
    Originally posted by kubicle View Post
    This should suffice:
    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    
    if xrandr | grep -q "DVI-I-3 connected 1920"
      then 
        xrandr --output DVI-I-3 --off
      else 
        xrandr --output DVI-I-3 --auto --right-of DVI-I-2
    fi
    Also added
    killall conky
    conky
    to get conky back in the right position.
    That works. Now I'll just make it into a shortcut, find a light switch icon (have to figure out how to assign an icon to a script) and throw it onto the panel.

    Looked everything over and I'm not sure how you figured that out. Would like to know as I might be able to apply to something in the future. If you would be so kind. Might help someone else too
    Last edited by vsreeser; Feb 14, 2015, 10:55 PM.

    Leave a comment:


  • Rod J
    replied
    I just modified my original script to update it with my new system (same two monitors though, but xrandr gives different results). It's working fine here.

    Toggle2ndMonitor.sh:
    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    # v1.1 changed to suit new system running Kubuntu 14.04
    
    if xrandr | grep -q "HDMI1 connected 1440x900+1680+0"
      then 
        xrandr --output HDMI1 --off
      else 
        xrandr --output HDMI1 --auto --right-of VGA1
    fi

    Leave a comment:


  • vinnywright
    replied
    Originally posted by vsreeser View Post
    I'm running Nvidia 346 driver, so icon in system settings non-functional.
    realy ,,,,,,I am running Nvidia-346.35 as well ,,,,,,and I can turn off the second display in system settings>display and monitor just fine ,,,,,,,,,,,, strange.

    VINNY

    Leave a comment:


  • kubicle
    replied
    This should suffice:
    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    
    if xrandr | grep -q "DVI-I-3 connected 1920"
      then 
        xrandr --output DVI-I-3 --off
      else 
        xrandr --output DVI-I-3 --auto --right-of DVI-I-2
    fi

    Leave a comment:


  • vsreeser
    replied
    Guess I could put two short cuts in the panel and just use the right one for each situation. But if we can find the right if statement, that would be nicer.

    Leave a comment:


  • vsreeser
    replied
    Originally posted by kubicle View Post
    The if statement might match both cases (monitor on and off), so the script always turns the monitor off (rather than toggling).

    First try if the command "xrandr --output DVI-I-3 --auto --right-of DVI-I-2" actually works and turns the monitor back on. If it does, post "xrandr" output from both states monitor on/off, so we can create a better if statement.
    xrandr --output DVI-I-3 --auto --right-of DVI-I-2 does turn the monitor back on.

    with monitor DVI-I-3 off
    Code:
    virgil@dads-kubuntu:~$ xrandr
    Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
    DVI-I-0 disconnected (normal left inverted right x axis y axis)
    DVI-I-1 disconnected (normal left inverted right x axis y axis)
    DVI-I-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
       1920x1080      60.0*+   59.9     50.0     60.1     60.0     50.0  
       1680x1050      60.0  
       1600x1200      60.0  
       1440x900       59.9  
       1400x1050      60.0  
       1280x1024      75.0     60.0  
       1280x960       60.0  
       1280x720       60.0     59.9     50.0  
       1152x864       75.0  
       1024x768       75.0     70.1     60.0  
       800x600        75.0     72.2     60.3     56.2  
       720x576        50.0     50.1  
       720x480        59.9     60.1  
       640x480        75.0     72.8     59.9     59.9  
    DVI-I-3 connected (normal left inverted right x axis y axis)
       1920x1080      60.0 +   59.9     50.0     60.1     60.0     50.0  
       1680x1050      60.0  
       1600x900       60.0  
       1280x1024      75.0     60.0  
       1280x960       60.0  
       1280x800       59.8  
       1280x720       60.0     59.9     50.0  
       1024x768       75.0     60.0  
       1024x576       60.0  
       800x600        75.0     60.3  
       720x576        50.0     50.1  
       720x480        59.9     60.1  
       640x480        75.0     59.9     59.9  
    HDMI-0 disconnected (normal left inverted right x axis y axis)
    with DVI-I-3 on
    Code:
    virgil@dads-kubuntu:~$ xrandr
    Screen 0: minimum 8 x 8, current 3840 x 1080, maximum 16384 x 16384                                                                                                                               
    DVI-I-0 disconnected (normal left inverted right x axis y axis)                                                                                                                                   
    DVI-I-1 disconnected (normal left inverted right x axis y axis)                                                                                                                                   
    DVI-I-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 597mm x 336mm                                                                                                  
       1920x1080      60.0*+   59.9     50.0     60.1     60.0     50.0                                                                                                                               
       1680x1050      60.0                                                                                                                                                                            
       1600x1200      60.0                                                                                                                                                                            
       1440x900       59.9                                                                                                                                                                            
       1400x1050      60.0                                                                                                                                                                            
       1280x1024      75.0     60.0                                                                                                                                                                   
       1280x960       60.0                                                                                                                                                                            
       1280x720       60.0     59.9     50.0                                                                                                                                                          
       1152x864       75.0                                                                                                                                                                            
       1024x768       75.0     70.1     60.0                                                                                                                                                          
       800x600        75.0     72.2     60.3     56.2                                                                                                                                                 
       720x576        50.0     50.1                                                                                                                                                                   
       720x480        59.9     60.1                                                                                                                                                                   
       640x480        75.0     72.8     59.9     59.9                                                                                                                                                 
    DVI-I-3 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 598mm x 336mm                                                                                                       
       1920x1080      60.0*+   59.9     50.0     60.1     60.0     50.0                                                                                                                               
       1680x1050      60.0                                                                                                                                                                            
       1600x900       60.0                                                                                                                                                                            
       1280x1024      75.0     60.0  
       1280x960       60.0  
       1280x800       59.8  
       1280x720       60.0     59.9     50.0  
       1024x768       75.0     60.0  
       1024x576       60.0  
       800x600        75.0     60.3  
       720x576        50.0     50.1  
       720x480        59.9     60.1  
       640x480        75.0     59.9     59.9  
    HDMI-0 disconnected (normal left inverted right x axis y axis)
    They seem to look the same. I've been looking for some way to find the status, but haven't found anything yet

    Leave a comment:


  • kubicle
    replied
    Originally posted by vsreeser View Post
    It turns it off. Halfway there. Tried changin --auto to --on. No effect. Back to research for a bit.
    The if statement might match both cases (monitor on and off), so the script always turns the monitor off (rather than toggling).

    First try if the command "xrandr --output DVI-I-3 --auto --right-of DVI-I-2" actually works and turns the monitor back on. If it does, post "xrandr" output from both states monitor on/off, so we can create a better if statement.

    Leave a comment:


  • vsreeser
    replied
    Originally posted by kubicle View Post
    Try:
    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    
    if xrandr | grep -q "DVI-I-3 connected"
      then 
        xrandr --output DVI-I-3 --off
      else 
        xrandr --output DVI-I-3 --auto --right-of DVI-I-2
    fi
    1. This assumes DVI-I-3 is the monitor you wish to turn off/on, and
    2. That the monitor DVI-I-3 is on the right side of DVI-I-2
    Also note that in DVI-I-X, the bold character is a capital "i" not the number "1"
    It turns it off. Halfway there. Tried changin --auto to --on. No effect. Back to research for a bit.

    Leave a comment:


  • kubicle
    replied
    Try:
    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    
    if xrandr | grep -q "DVI-I-3 connected"
      then 
        xrandr --output DVI-I-3 --off
      else 
        xrandr --output DVI-I-3 --auto --right-of DVI-I-2
    fi
    1. This assumes DVI-I-3 is the monitor you wish to turn off/on, and
    2. That the monitor DVI-I-3 is on the right side of DVI-I-2
    Also note that in DVI-I-X, the bold character is a capital "i" not the number "1"

    Leave a comment:


  • vsreeser
    replied
    Originally posted by kubicle View Post
    What's the output of "xrandr"?
    Code:
    virgil@dads-kubuntu:~$ xrandr
    Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
    DVI-I-0 disconnected (normal left inverted right x axis y axis)
    DVI-I-1 disconnected (normal left inverted right x axis y axis)
    DVI-I-2 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
       1920x1080      60.0*+   59.9     50.0     60.1     60.0     50.0  
       1680x1050      60.0  
       1600x1200      60.0  
       1440x900       59.9  
       1400x1050      60.0  
       1280x1024      75.0     60.0  
       1280x960       60.0  
       1280x720       60.0     59.9     50.0  
       1152x864       75.0  
       1024x768       75.0     70.1     60.0  
       800x600        75.0     72.2     60.3     56.2  
       720x576        50.0     50.1  
       720x480        59.9     60.1  
       640x480        75.0     72.8     59.9     59.9  
    DVI-I-3 connected (normal left inverted right x axis y axis)
       1920x1080      60.0 +   59.9     50.0     60.1     60.0     50.0  
       1680x1050      60.0  
       1600x900       60.0  
       1280x1024      75.0     60.0  
       1280x960       60.0  
       1280x800       59.8  
       1280x720       60.0     59.9     50.0  
       1024x768       75.0     60.0  
       1024x576       60.0  
       800x600        75.0     60.3  
       720x576        50.0     50.1  
       720x480        59.9     60.1  
       640x480        75.0     59.9     59.9  
    HDMI-0 disconnected (normal left inverted right x axis y axis)
    DVI-1-0 And DVI-1-1 ar from built in video. Horrid performance (aren't they all), so I put in a decent card. I'm running Nvidia 346 driver, so icon in system settings non-functional.

    Tried modifying script from Rod J to
    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    
    if xrandr | grep -q "DVI-1-3 connected 1920x1020+1920+0"
      then 
        xrandr --output DVI-1-3 --off
      else 
        xrandr --output DVI-1-3 --auto --right-of VGA-0
    fi
    but got
    Code:
    virgil@dads-kubuntu:~$ sh monitorswitch.sh 
    xrandr: cannot find output "VGA-0"
    monitor on and off when testing, same result when using DFP-1 instead of VGA-0 and wether second monitor is on or off

    What should I use in place of VGA-0 in the script? Nvidia settings calls left Monitor Viewsonic VC2753 Series(DFP-0), right is Benq GW2750H(DFP-1)

    I think I try to automate too much, but something to work on, it keeps the kids off my computer because they can;t figure it out

    Leave a comment:


  • vinnywright
    replied
    system settings>display and monitor>uncheck (click) the second monitor and click apply ,,,,,,,ya 5 clicks ,,,,,but hay it's easy.

    VINNY

    Leave a comment:


  • Rod J
    replied
    I wrote this little script a while back to toggle the second monitor on or off. I didn't like my videos being split between the monitors much like your game problem. This script worked perfectly in 12.04 but I haven't tested or modified it for 14.04 yet. You will need to modify it to suit your particular settings (screen resolution, 2nd monitor postition, etc). You need to look at the output of the xrandr program to determine what to change in the script below.

    Code:
    #!/bin/sh
    # Toggle the second monitor On or Off depending on its current state.
    
    if xrandr | grep -q "DVI-0 connected 1440x900+1680+0"
      then 
        xrandr --output DVI-0 --off
      else 
        xrandr --output DVI-0 --auto --right-of VGA-0
    fi

    Leave a comment:

Users Viewing This Topic

Collapse

There are 0 users viewing this topic.

Working...
X