| 1 | package X11::XRandR::State; | ||||||||||
| 2 | |||||||||||
| 3 | # ABSTRACT: The XRandR state | ||||||||||
| 4 | |||||||||||
| 5 | 1 | ▶ | use Pegex::Parser; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use X11::XRandR::Grammar::Verbose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use X11::XRandR::Receiver::Verbose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use Types::Standard -types; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use IPC::Cmd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use MooX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | our $VERSION = '0.01'; | |||||||||
| 18 | |||||||||||
| 19 | #pod =attr screen | ||||||||||
| 20 | #pod | ||||||||||
| 21 | #pod An instance of L<X11::XRandR::Screen>. | ||||||||||
| 22 | #pod | ||||||||||
| 23 | #pod =cut | ||||||||||
| 24 | |||||||||||
| 25 | 1 | has screen => ( | |||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | isa => InstanceOf ['X11::XRandR::Screen'], | ||||||||||
| 28 | required => 1, | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | #pod =attr outputs | ||||||||||
| 32 | #pod | ||||||||||
| 33 | #pod An array of L<X11::XRandR::Output> objects | ||||||||||
| 34 | #pod | ||||||||||
| 35 | #pod =cut | ||||||||||
| 36 | |||||||||||
| 37 | 1 | has outputs => ( | |||||||||
| 38 | is => 'ro', | ||||||||||
| 39 | isa => ArrayRef [ InstanceOf ['X11::XRandR::Output'] ], | ||||||||||
| 40 | required => 1, | ||||||||||
| 41 | ); | ||||||||||
| 42 | |||||||||||
| 43 | #pod =method query | ||||||||||
| 44 | #pod | ||||||||||
| 45 | #pod A class method to query XRandR for its state using the C<xrandr> command. | ||||||||||
| 46 | #pod Returns an instance of L<X11::XRandR::State>. | ||||||||||
| 47 | #pod | ||||||||||
| 48 | #pod =cut | ||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub query { | ||||||||
|
Subroutine
query: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | ▶ | IPC::Cmd::can_run( 'xrandr' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | or Carp::croak( "xrandr command is not in path\n" ); | ||||||||||
| 54 | |||||||||||
| 55 | 0 | my ( $success, $error_message, undef, $stdout_buf, undef ) | |||||||||
| 56 | = IPC::Cmd::run( | ||||||||||
| 57 | command => [qw ( xrandr --verbose )], | ||||||||||
| 58 | verbose => 0 | ||||||||||
| 59 | ); | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | Carp::croak( "error running xrandr: $error_message\n" ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | if length $error_message; | ||||||||||
| 63 | |||||||||||
| 64 | 0 | my $parser = Pegex::Parser->new( | |||||||||
| 65 | grammar => X11::XRandR::Grammar::Verbose->new, | ||||||||||
| 66 | receiver => X11::XRandR::Receiver::Verbose->new | ||||||||||
| 67 | ); | ||||||||||
| 68 | |||||||||||
| 69 | 0 | $parser->parse( join( '', @$stdout_buf ) ); | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | #pod =method to_string | ||||||||||
| 73 | #pod | ||||||||||
| 74 | #pod Return a string rendition of the object just as B<xrandr> would. | ||||||||||
| 75 | #pod | ||||||||||
| 76 | #pod =cut | ||||||||||
| 77 | |||||||||||
| 78 | |||||||||||
| 79 | 1 | 1; | |||||||||
| 80 | |||||||||||
| 81 | # | ||||||||||
| 82 | # This file is part of X11-XRandR | ||||||||||
| 83 | # | ||||||||||
| 84 | # This software is Copyright (c) 2018 by Diab Jerius. | ||||||||||
| 85 | # | ||||||||||
| 86 | # This is free software, licensed under: | ||||||||||
| 87 | # | ||||||||||
| 88 | # The GNU General Public License, Version 3, June 2007 | ||||||||||
| 89 | # | ||||||||||
| 90 | |||||||||||
| 91 | __END__ | ||||||||||