How can I turn off my laptop's screen after a period of inactivity?

I have an ASUS VivoBook I recently set up as a server, but I can't figure out how to turn off its screen. Here's my /etc/rc.conf:
Code:
clear_tmp_enable="YES"
syslogd_flags="-ss"
hostname="freebsd"
keymap="si.kbd"
ifconfig_ue0="DHCP"
ifconfig_ue0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
ntpd_enable="YES"
ntpd_sync_on_start="YES"
local_unbound_enable="YES"
powerd_enable="YES"
moused_enable="NO"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
blanktime=600
saver="green"

It doesn't turn off after 10 minutes of inactivity as one would expect. I don't have a GUI or anything like that, just a TTY. Preferably, I'd like to make it so that, if needed, the screen can still be turned on for a bit just by typing something on the keyboard.

I've also tried using vidcontrol():
Code:
gregor@freebsd:~ % sudo vidcontrol -t 1
vidcontrol: getting active vty: Inappropriate ioctl for device
gregor@freebsd:~ % sudo sh -c 'vidcontrol -t 1 < /dev/ttyv0'

Nothing happens.

Here's some info about my system:

Code:
gregor@freebsd:~ % sudo inxi -M
Duplicate specification "debug-width|debug-y|debug-zy:i" for option "debug-zy"
Machine:
  Type: Notebook Mobo: ASUSTeK model: X430FA v: 1.0 serial: QCCXKL1TF90301427
    UEFI: American Megatrends v: X430FA.309 date: 07/03/2020
gregor@freebsd:~ % inxi -SCG --display
Duplicate specification "debug-width|debug-y|debug-zy:i" for option "debug-zy"
System:
  Host: freebsd Kernel: FreeBSD 15.1-RELEASE-p6 amd64 bits: 64 Desktop: N/A
    OS: FreeBSD 15.1-RELEASE-p6
CPU:
  Info: 8-core model: Intel Core i5-8265U bits: 64 type: MCP cache: N/A
  Speed (MHz): 1800 min/max: N/A cores: No OS support for core speeds.
Graphics:
  Device-1: Intel WhiskeyLake-U GT2 [UHD Graphics 620] driver: vgapci
  Display: server: No display server data found. Headless machine?
  Message: No advanced graphics data found on this system.
 
I doubt if the TTY screensaver feature was only designed to work with syscons which is deprecated and now we have to use VT instead. Could you see a reference to that in the man pages, maybe?

Another thing is that vidcontrol may not work when using some terminal multiplexer such as tmux.
 
if you have a working backlight(8) you can look at /dev/ttyv0 mtime and use backlight from a script or cron
I just managed to get backlight working so I can at least turn the screen off so it doesn't bother people at night, I'll try to craft a script tomorrow :D
 
Everything in this regard is controlled by ACPI.

So you can taylor set your BIOS S3/S4 sleep mode settings or use the built in mode.

acpiconf -s 3

sysctl hw.acpi.supported_sleep_state
 
i think screensavers require syscons and wont work with vt(4)
Screensaver’s not yet implemented in vt(4); it’s listed in the Wiki as unstarted (potentially inaccessible because of Аnubіs).​
[…] To me it seems like turning off the backlight is not really turning off video right? […]
Confirmed. If I turn off the backlight and shine a lamp at the right angle, I can still discern the characters and see the screen contents getting updated.​
I have an ASUS VivoBook I recently set up as a server, but I can't figure out how to turn off its screen. […]
Does the BIOS turn off the screen via the lid switch? Now you don’t want to build‑up heat (permanently operate with screen closed), but maybe you can manipulate the lid switch.​
 
Thanks, is there any way I could achieve something like the green screensaver's behaviour with vt or should I switch to syscons?
If your computer can boot via legacy BIOS (include CSM on UEFI) and if you don't need any characters NOT included in CP437, you can, currently.

If your computer can boot via pure UEFI (without CSM) only, you cannot use syscons. This is because syscons depends on ancient text VRAMs that UEFI alone does NOT have (CSM emulates as if text VRAM exists on UEFI, but not all UEFI firmwares are assured to have it).

But deletion of deprecated syscons is delayed and delayed, as of lack of functionalities syscons had. Hope vt obtains screensaver supports before syscons is actually deleted.
 
Nothing happens.
Yes vidcontrol only works on the older sc(4) console.

I see you are not running any video drivers.
That would mean you could implement sc(4) since you are command line only.
There really no drawbacks that I can think of with sc(4) if you are using base video driver.

Only if using Xorg does it become problematic.
is there any way I could achieve something like the green screensaver's behaviour with vt or should I switch to syscons?
Just switch. Its easy enough to try and there is no drawback. Different fonts.
I have older boxes that won't work with vt(4) and I can say they work fine for me.
Like Tom mentions your BIOS needs legacy or CSM mode for SC
 
The drawbacks are that if this is an existing installation you have EFI partition for booting and need to switch to a FreeBSD boot partition.

So there is a major drag.

You could setup your machine for either type partition scheme with two small partitions.
One for EFI and one for FreeBSD Boot Partition..

Maybe split up the the existing EFI partition. That gets messy.
 
For anyone who also needs a solution to this, I made a bash script to turn off the backlight if there is no activity for at least 10 minutes, as suggested by covacat:
Bash:
#!/usr/local/bin/bash

diff=$(expr $(date +%s) - $(stat -f %m /dev/ttyv0))

if [[ "$diff" -gt 600 ]]; then backlight 0; else backlight 100; fi

and the crontab:

Code:
* * * * * for i in $(jot 60); do /usr/local/bin/screencheck & sleep 1; done
 
Back
Top