I can't turn off the display with function keys

Hello everyone,

I have an issue that I hope you can help me with. I’m trying to turn off the screen on my Linux system using the key combination FN+F7. However, it seems that Linux doesn’t recognize this combination, even though it works perfectly on Windows. When I attempt to set a shortcut using these keys on Linux, it appears as if no keys are being pressed. Can anyone provide guidance on how to fix this? Your assistance would be greatly appreciated. Thank you!

System:
  Kernel: 6.1.41-1-MANJARO arch: x86_64 bits: 64 compiler: gcc v: 13.1.1
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.1-x86_64
    root=UUID=86f07d22-9ea2-43d7-b717-f40303fc6e9a rw quiet splash
    udev.log_priority=3 acpi_osi=Linux acpi_sleep=nonvs
  Desktop: KDE Plasma v: 5.27.6 tk: Qt v: 5.15.10 wm: kwin_x11 vt: 2 dm: SDDM
    Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: ASUSTeK product: GL702VM v: 1.0
    serial: <superuser required>
  Mobo: ASUSTeK model: GL702VM v: 1.0 serial: <superuser required>
    UEFI: American Megatrends v: GL702VM.310 date: 04/29/2019
Battery:
  ID-1: BAT0 charge: N/A condition: N/A volts: N/A model: N/A type: Unknown
    serial: N/A status: not charging
Memory:
  System RAM: total: 32 GiB available: 31.29 GiB used: 10.67 GiB (34.1%)
  RAM Report: permissions: Unable to run dmidecode. Root privileges required.
CPU:
  Info: model: Intel Core i7-6700HQ bits: 64 type: MT MCP arch: Skylake-S
    gen: core 6 level: v3 note: check built: 2015 process: Intel 14nm family: 6
    model-id: 0x5E (94) stepping: 3 microcode: 0xF0
  Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache:
    L1: 256 KiB desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB
    L3: 6 MiB desc: 1x6 MiB
  Speed (MHz): avg: 1309 high: 1386 min/max: 800/3500 scaling:
    driver: intel_pstate governor: powersave cores: 1: 1300 2: 1276 3: 1300
    4: 1317 5: 1300 6: 1298 7: 1386 8: 1298 bogomips: 41621
  Flags: 3dnowprefetch abm acpi adx aes aperfmperf apic arat
    arch_capabilities arch_perfmon art avx avx2 bmi1 bmi2 bts clflush
    clflushopt cmov constant_tsc cpuid cpuid_fault cx16 cx8 de ds_cpl dtes64
    dtherm dts epb ept ept_ad erms est f16c flexpriority flush_l1d fma fpu
    fsgsbase fxsr ht hwp hwp_act_window hwp_epp hwp_notify ibpb ibrs ida
    intel_pt invpcid invpcid_single lahf_lm lm mca mce md_clear mmx monitor
    movbe mpx msr mtrr nonstop_tsc nopl nx pae pat pbe pcid pclmulqdq pdcm
    pdpe1gb pebs pge pln pni popcnt pse pse36 pti pts rdrand rdseed rdtscp
    rep_good sdbg sep smap smep ss ssbd sse sse2 sse4_1 sse4_2 ssse3 stibp
    syscall tm tm2 tpr_shadow tsc tsc_adjust tsc_deadline_timer vme vmx vnmi
    vpid x2apic xgetbv1 xsave xsavec xsaveopt xsaves xtopology xtpr
  Vulnerabilities:
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf mitigation: PTE Inversion; VMX: conditional cache flushes, SMT
    vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: retbleed mitigation: IBRS
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: IBRS, IBPB: conditional, STIBP: conditional,
    RSB filling, PBRSB-eIBRS: Not affected
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort mitigation: TSX disabled
Graphics:
  Device-1: NVIDIA GP106BM [GeForce GTX 1060 Mobile 6GB] vendor: ASUSTeK
    driver: nvidia v: 535.86.05 alternate: nouveau,nvidia_drm non-free: 535.xx+
    status: current (as of 2023-07) arch: Pascal code: GP10x process: TSMC 16nm
    built: 2016-21 pcie: gen: 3 speed: 8 GT/s lanes: 16 bus-ID: 01:00.0
    chip-ID: 10de:1c60 class-ID: 0300
  Device-2: IMC Networks USB2.0 HD UVC WebCam driver: uvcvideo type: USB
    rev: 2.0 speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-4:2 chip-ID: 13d3:5666
    class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org v: 21.1.8 with: Xwayland v: 23.1.2
    compositor: kwin_x11 driver: X: loaded: nvidia gpu: nvidia display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 25 s-size: 1951x1097mm (76.81x43.19")
    s-diag: 2238mm (88.12")
  Monitor-1: DP-4 res: 1920x1080 hz: 60 dpi: 128
    size: 382x215mm (15.04x8.46") diag: 438mm (17.26") modes: N/A
  API: OpenGL v: 4.6.0 NVIDIA 535.86.05 renderer: NVIDIA GeForce GTX
    1060/PCIe/SSE2 direct-render: Yes
Audio:
  Device-1: Intel 100 Series/C230 Series Family HD Audio vendor: ASUSTeK
    driver: snd_hda_intel v: kernel bus-ID: 00:1f.3 chip-ID: 8086:a170
    class-ID: 0403
  Device-2: NVIDIA GP106 High Definition Audio vendor: ASUSTeK
    driver: snd_hda_intel v: kernel pcie: gen: 3 speed: 8 GT/s lanes: 16
    bus-ID: 01:00.1 chip-ID: 10de:10f1 class-ID: 0403
  API: ALSA v: k6.1.41-1-MANJARO status: kernel-api with: aoss
    type: oss-emulator tools: alsactl,alsamixer,amixer
  Server-1: JACK v: 1.9.22 status: off tools: N/A
  Server-2: PipeWire v: 0.3.75 status: off with: wireplumber status: active
    tools: pw-cli,wpctl
  Server-3: PulseAudio v: 16.1 status: active with: pulseaudio-alsa
    type: plugin tools: pacat,pactl
Network:
  Device-1: Intel Wireless 7265 driver: iwlwifi v: kernel pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 bus-ID: 02:00.0 chip-ID: 8086:095a class-ID: 0280
  IF: wlp2s0 state: up mac: <filter>
  IP v4: <filter> type: dynamic noprefixroute scope: global
    broadcast: <filter>
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: ASUSTeK driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s lanes: 1
    port: d000 bus-ID: 03:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: enp3s0 state: down mac: <filter>
  Device-3: KYE Systems (Mouse Systems) GF3000F Ethernet Adapter
    driver: hid-generic,usbhid type: USB rev: 1.1 speed: 12 Mb/s lanes: 1
    mode: 1.1 bus-ID: 1-6:9 chip-ID: 0458:6001 class-ID: 0301
  WAN IP: <filter>
Bluetooth:
  Device-1: Intel Bluetooth wireless interface driver: btusb v: 0.8 type: USB
    rev: 2.0 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-9:5 chip-ID: 8087:0a2a
    class-ID: e001
  Report: rfkill ID: hci0 rfk-id: 2 state: up address: see --recommends
Logical:
  Message: No logical block device data found.
RAID:
  Message: No RAID data found.
Drives:
  Local Storage: total: 1.82 TiB used: 1.26 TiB (69.3%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung
    model: SSD 970 EVO Plus 1TB size: 931.51 GiB block-size: physical: 512 B
    logical: 512 B speed: 31.6 Gb/s lanes: 4 tech: SSD serial: <filter>
    fw-rev: 2B2QEXM7 temp: 52.9 C scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: HGST (Hitachi) model: HTS721010A9E630
    size: 931.51 GiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
    tech: HDD rpm: 7200 serial: <filter> fw-rev: A3V0 scheme: GPT
  Message: No optical or floppy data found.
Partition:
  ID-1: / raw-size: 139.7 GiB size: 136.45 GiB (97.67%) used: 43.27 GiB (31.7%)
    fs: ext4 dev: /dev/nvme0n1p4 maj-min: 259:4 label: N/A
    uuid: 86f07d22-9ea2-43d7-b717-f40303fc6e9a
  ID-2: /boot/efi raw-size: 953 MiB size: 951.1 MiB (99.80%)
    used: 308 KiB (0.0%) fs: vfat dev: /dev/nvme0n1p6 maj-min: 259:6 label: N/A
    uuid: 3DD5-49D0
  ID-3: /home raw-size: 182.54 GiB size: 178.61 GiB (97.85%)
    used: 42.65 GiB (23.9%) fs: ext4 dev: /dev/nvme0n1p5 maj-min: 259:5
    label: N/A uuid: 4d2fa0f1-a0e3-4689-908f-594ba5cae0e8
  ID-4: /mnt/Repository raw-size: 931.51 GiB size: 931.51 GiB (100.00%)
    used: 822.18 GiB (88.3%) fs: ntfs dev: /dev/sda4 maj-min: 8:4
    label: Repository uuid: 9A767CBB767C99A9
  ID-5: /mnt/Windows raw-size: 575.63 GiB size: 575.63 GiB (100.00%)
    used: 382.82 GiB (66.5%) fs: ntfs dev: /dev/nvme0n1p2 maj-min: 259:2
    label: Windows 11 uuid: 01D5C893E9C076B0
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default)
  ID-1: swap-1 type: partition size: 32.46 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/nvme0n1p3 maj-min: 259:3 label: N/A
    uuid: 4badc183-3ffe-4dc1-8c35-e7d2ff44497e
Unmounted:
  ID-1: /dev/nvme0n1p1 maj-min: 259:1 size: 260 MiB fs: vfat label: SYSTEM
    uuid: CAC8-3BE2
USB:
  Hub-1: 1-0:1 info: hi-speed hub with single TT ports: 16 rev: 2.0
    speed: 480 Mb/s (57.2 MiB/s) lanes: 1 mode: 2.0 chip-ID: 1d6b:0002
    class-ID: 0900
  Device-1: 1-4:2 info: IMC Networks USB2.0 HD UVC WebCam type: video
    driver: uvcvideo interfaces: 2 rev: 2.0 speed: 480 Mb/s (57.2 MiB/s) lanes: 1
    mode: 2.0 power: 500mA chip-ID: 13d3:5666 class-ID: 0e02 serial: <filter>
  Device-2: 1-6:9 info: KYE Systems (Mouse Systems) GF3000F Ethernet Adapter
    type: mouse,keyboard driver: hid-generic,usbhid interfaces: 3 rev: 1.1
    speed: 12 Mb/s (1.4 MiB/s) lanes: 1 mode: 1.1 power: 100mA
    chip-ID: 0458:6001 class-ID: 0301
  Device-3: 1-8:4 info: ASUSTek ROG MacroKey type: keyboard,mouse
    driver: asus,usbhid interfaces: 3 rev: 2.0 speed: 12 Mb/s (1.4 MiB/s)
    lanes: 1 mode: 1.1 power: 100mA chip-ID: 0b05:1837 class-ID: 0301
  Device-4: 1-9:5 info: Intel Bluetooth wireless interface type: bluetooth
    driver: btusb interfaces: 2 rev: 2.0 speed: 12 Mb/s (1.4 MiB/s) lanes: 1
    mode: 1.1 power: 100mA chip-ID: 8087:0a2a class-ID: e001
  Hub-2: 2-0:1 info: super-speed hub ports: 8 rev: 3.0
    speed: 5 Gb/s (596.0 MiB/s) lanes: 1 mode: 3.2 gen-1x1 chip-ID: 1d6b:0003
    class-ID: 0900
Sensors:
  System Temperatures: cpu: 66.0 C pch: 60.0 C mobo: N/A gpu: nvidia temp: 72 C
  Fan Speeds (RPM): cpu: 3400
Info:
  Processes: 338 Uptime: 2h 11m wakeups: 4 Init: systemd v: 253
  default: graphical tool: systemctl Compilers: gcc: 13.1.1 clang: 15.0.7
  Packages: 1518 pm: pacman pkgs: 1478 libs: 463 tools: pamac pm: flatpak
  pkgs: 40 Shell: Zsh v: 5.9 default: Bash v: 5.1.16 running-in: konsole
  inxi: 3.3.28

FN key combo is usually baked in to the keyboard firmware.

Since you use KDE Plasma, you can utilize Custom Shortcuts feature of the System Settings. Follow the red arrows:


click on the newly created action, go to Trigger tab, then click the “None” in the shortcut input box, it should change to “Input …”. Now press FN+F7, let be whatever is written there afterwards, though you might want to remember the name of the generated key symbol just in case.

Now go to the Action tab and fill it with:

xset dpms force off

install xorg-xset if you don’t have one in the first place. Click Apply, you can close System Settings now and try that shortcut.

1 Like

Thank you for providing your explanation. The issue I’m facing is that when I press the combination of FN+F7, it doesn’t seem to recognize the input, as if I haven’t pressed FN+F7 at all. The system still waits for me to push additional keys.

Have you tried F7 on it’s own?

My laptop has an option in UEFI, “Action keys mode”, it switches the behaviour. When disabled F7 = F7 and Fn + F7 = action, and when enabled F7 = action and Fn + F7 = F7.

Install evtest, sudo evtest, and select your keyboard from the list (there may be several options for your keyboard). Press a key, if it’s not recognised then Ctrl + C (or Ctrl + Alt + C) to quit and pick another.

Then probably best to start fresh, to avoid cluttered output, and then test F7 and Fn + F7. Post the output, we don’t need the bit at the top, just the responses to the keys.

Example Output
Event: time 1690734083.155048, type 4 (EV_MSC), code 4 (MSC_SCAN), value 41
Event: time 1690734083.155048, type 1 (EV_KEY), code 65 (KEY_F7), value 1
Event: time 1690734083.155048, -------------- SYN_REPORT ------------
Event: time 1690734083.234763, type 4 (EV_MSC), code 4 (MSC_SCAN), value 41
Event: time 1690734083.234763, type 1 (EV_KEY), code 65 (KEY_F7), value 0
Event: time 1690734083.234763, -------------- SYN_REPORT ------------
Event: time 1690734086.632594, type 4 (EV_MSC), code 4 (MSC_SCAN), value a2
Event: time 1690734086.632594, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1
Event: time 1690734086.632594, -------------- SYN_REPORT ------------
Event: time 1690734086.705911, type 4 (EV_MSC), code 4 (MSC_SCAN), value a2
Event: time 1690734086.705911, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0
Event: time 1690734086.705911, -------------- SYN_REPORT ------------

If it’s not detected then one of your keys may be broken, but we might be able to remap it.

1 Like

your Bios is from 2019. please check for the latest bios avaiable first.

Thank you for providing your answer. Actually, my UEFI settings don’t include the option to remap keys, so I have to press the “fn” key in combination with other keys to utilize their functions. I ran the “evtest” utility, and it successfully recognized the key. Here is the output:

Event: time 1690738104.443993, type 4 (EV_MSC), code 4 (MSC_SCAN), value ff310035
Event: time 1690738104.443993, type 1 (EV_KEY), code 245 (KEY_DISPLAY_OFF), value 1
Event: time 1690738104.443993, -------------- SYN_REPORT ------------
Event: time 1690738104.547964, type 4 (EV_MSC), code 4 (MSC_SCAN), value ff310035
Event: time 1690738104.547964, type 1 (EV_KEY), code 245 (KEY_DISPLAY_OFF), value 0
Event: time 1690738104.547964, -------------- SYN_REPORT ------------

Thank you for your response. I appreciate your help. Unfortunately, it seems that I already have the latest BIOS version installed, so updating it further is not an option at the moment.

Is this when trying to put the key combo in Trigger tab or where?

That seems to be what’s expected, so at least evdev can recognize. But can xev recognize, too?

Exactly! It happens when I’m trying to put the key combo!

Yes, ‘xev’ recognize it too and this is the output:

KeyPress event, serial 47, synthetic NO, window 0x8000001,
    root 0x1c7, subw 0x0, time 5335675, (158,-22), root:(1029,420),
    state 0x10, keycode 253 (keysym 0x100810f5, XF86DisplayOff), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 47, synthetic NO, window 0x8000001,
    root 0x1c7, subw 0x0, time 5335803, (158,-22), root:(1029,420),
    state 0x10, keycode 253 (keysym 0x100810f5, XF86DisplayOff), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

excuse me if i’m dragging this off-topic, but all efforts where i tried to turn off my screen using key shortcut (i.e. F7) does trigger a screen off, only to wake screen immediately after. (its as if key-press triggers & key-release wakes the screen, … i think)

i’ve resorted to turn off screen using a start menu item.

Since the key is detected at a lower level, we can remap the keycode to another keysym, such as XF86Display or F23, or an unused keysym.

Assuming suitable choice of keysym (both suggestions work) it will be detected by the shortcut utility.

# dump config
xkbcomp $DISPLAY ~/.xkbmap.bak

# edit config
sed 's/XF86DisplayOff/XF86Display/' ~/.xkbmap.bak > ~/.xkbmap

# apply new config
xkbcomp ~/.xkbmap $DISPLAY

Now, by default, the key should trigger the KDE Daemon Switch Display thingy.

It can also be bound to a custom shortcut, which will disable that key for the Display Switch (Meta + P will still work¹), but if you prefer you can replace XF86Display with F23 or an unused keysym.

So now @leledumbo’s suggestion will work with this key, create a custom shortcut which calls xset dpms force off and set the “Trigger” to the key or combo you want.

If you use a combo (ie not just Fn + F7) then add a sleep 1 like so:

sleep 1; xset dpms force off

You can try values less than 1s, but for me nothing less than 1s works.

If you want to, you can create a different shortcut for "Switch Display"², by default there’s Meta + P and Display (which is XF86Display).

To make the key’s configuration permanent, create a script³.

~/.local/bin/xkbmap

#!/usr/bin/bash

xkbcomp ~/.xkbmap $DISPLAY

Then set it to be autostarted.

System Settings → Startup and Shutdown → Autostart → Add → Add Login Script


This won’t work on wayland, for that there are perhaps other options, at least some of these should work for X11 as well, though I’m not sure if they have the same functionality.

https://wiki.archlinux.org/title/Input_remap_utilities

¹Meta is normally the Alt key, but in KDE/Plasma it’s the windows key
²System Settings → Shortcuts → Shortcuts → KDE Daemon → Switch Display
³There doesn’t seem to be a way to autostart a command without a script, but I’m new to KDE :man_shrugging:

1 Like

Thank you for your response and assistance.

However, the issue remains that I want this key combination to specifically turn off the screen rather than just switching the display. Is there any guidance or solution you can provide to achieve this functionality? I appreciate your support in resolving this matter.

That’s why I said:

:smiley:

It’s not really a combo, the Fn key is internal to the keyboard (it just changes which scancode is sent) so the computer receives a single key.

Now you can bind the key, @leledumbo’s suggestion (custom shortcut with xset dpms force off) should work, any key press or mouse/touchpad movement should wake it up again.

If that’s not what you want, then you need to explain exactly what behaviour you do want so we can find the correct command(s).

In case you'd be interested in also preserving the switch display functionality

You can use both a custom shortcut and the Display Switch OSD*. Assign one to the key on it’s own (Fn + F7) and the other to a combo such as Shift + Fn + F7.

*You can define a custom shortcut for Switch Display in Settings → Shortcuts → Shortcuts → KDE Daemon → Switch Display.

Of course you can also just use any other key or combo.

:smiley:

EDIT:

I’ve re-written my previous post to be more concise and hopefully a little clearer.

There are apparently a number of ways to do this. On my system it looks like this using xset:

#!/bin/bash
sleep 1; xset dpms force off

The script is assigned Alt + x, since x is the display. :wink:

You can put that directly in the “Command/URL” box. No need for a script…unless you want one. :smiley:

Works without a delay for me. Do you have a problem similar to @koshikas, or is it just preference?

@koshikas What command did you use to turn off the display? Did you try a delay?

Just a preference and what I learned an age ago.
Not sure why I put the sleep command in there.

Maybe because the release of the x button woke the screen up right away again.

1 Like

I think it’s more likely to be the modifiers (they tend to be released last). Some slightly less pathetic testing (than I did earlier) has revealed Alt + X and other combos indeed do wake it up again, but not always.

For me, F4 and F7 seem fine, as does XF86Display so single keys seem to work, but there’s not many to test without binding to other keysyms. Maybe I’ll try a few more tomorrow.

so far i’ve been trying without a delay and didnt work. with default F7 key binding and other custom key shortcuts i’ve tried with xset dpms force off have all worked to off the screen but wakes it immediately after, so my assumption was that key release triggered the screen wake.

with the delay it works, for people who find 1s too much of a delay, you can use decimal fractions with sleep command.

Thanks!

1 Like

Thanks, I’d forgotten about that. :smiley:

EDIT:

Just tested and nothing below 1s works for me.