set_backlight_brightness Subroutine

private impure elemental subroutine set_backlight_brightness(this, brightness)

Type Bound

linux_backlight

Arguments

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

Contents


Source Code

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

      this%brightness = brightness

      file_name = this%path_backlight//"/brightness"
      inquire(file=file_name, exist=ex)
      if (ex) then
         open(newunit=nunit, file=file_name, iostat=stat)
         write(nunit, '(i0)') this%brightness
         close(nunit)
      else
         ! error stop "file not found: "//file_name
      endif
   end subroutine set_backlight_brightness