Guest User

dual monitor on/off

a guest
Oct 31st, 2013
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Gtk2 '-init';
  4. mk_main_window();
  5. Gtk2->main;
  6. sub mk_main_window {
  7. my $mw = Gtk2::Window->new;
  8. $mw->signal_connect (destroy => \&close_this_app );
  9. $mw->set_title ("Monitors");
  10. my $vbox0 = Gtk2::VBox->new();
  11. $mw->add($vbox0);
  12. my $b1 = Gtk2::Button->new("Turn Second Monitor ON");
  13. $b1->signal_connect(clicked=> \&turn_monitor_on);
  14. $vbox0->add($b1);
  15. my $b3 = Gtk2::Button->new("Turn Second Monitor OFF");
  16. $b3->signal_connect(clicked=> \&turn_monitor_off);
  17. $vbox0->add($b3);
  18. $mw->show_all();
  19. }
  20. sub turn_monitor_on {
  21. system("xrandr --output VGA-0 --auto --output DVI-I-0 --auto --right-of VGA-0");
  22. close_this_app();
  23. }
  24. sub turn_monitor_off {
  25. system("xrandr --output DVI-I-0 --off");
  26. close_this_app();
  27. }
  28. sub close_this_app {
  29. Gtk2->main_quit;
  30. }
RAW Paste Data