select_backlight Subroutine

private impure elemental subroutine select_backlight(this)

Type Bound

linux_backlight

Arguments

Type IntentOptional Attributes Name
class(linux_backlight), intent(inout) :: this

Contents

Source Code


Source Code

   elemental impure subroutine select_backlight(this)
      class(linux_backlight), intent(inout) :: this
      integer                               :: nunit, stat
      logical                               :: ex
      character(len=:), allocatable         :: file_name

      ! read actual brightness
      file_name = this%path_backlight//"/actual_brightness"
      inquire(file=file_name, exist=ex)
      if (ex) then
         open(newunit=nunit, file=file_name, iostat=stat)
         read(nunit, *) this%actual_brightness
         close(nunit)
      else
         this%actual_brightness = 0
         ! error stop "file not found: "//file_name
      endif

      ! read max brightness
      file_name = this%path_backlight//"/max_brightness"
      inquire(file=file_name, exist=ex)
      if (ex) then
         open(newunit=nunit, file=file_name, iostat=stat)
         read(nunit, *) this%max_brightness
         close(nunit)
      else
         this%max_brightness = 0
         ! error stop "file not found: "//file_name
      endif

   end subroutine select_backlight