Bluetooth systray widget stops working when suspend

Hello.
im having an interesting bug with bluetooth widget on plasmashell. steps to reproduce:
1)enable bluetooth and connect to anything (headphones in my case)
2)suspend to ram (via kde plasma menu, systemctl suspend or even echo mem > /sys/power/state, all works the same)
3)resume
bluetooth is enabled on resume, it even connects to my headphones automatically, but bluetooth tray widget doesnt show that. instead it says that "no devices found" (even tho it may enable and disable it) untill you restart plasmashell (i do pkill plasmashell; kstart5 plasmashell) then it works fine again. and in systemsettings app bluetooth works fine always.
so i either just use settings now or restart plasmashell every time. both ways are annoying so i just wonder if someone face this problem as well or there is a solution

i already tried lts kernel and disabled bluetooth-autoconnect.service. standalone widget (outside the tray, like on desktop) works the same way. any ideas to try?

garuda-inxi
perl: warning: Setting locale failed.
*other locale settings warnings i dont care anyway*
System:
  Kernel: 5.16.8-zen1-1-zen x86_64 bits: 64 compiler: gcc v: 11.1.0
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=a162ca6f-d8e8-47fb-89af-c723071373f9 rw rootflags=subvol=@
    selinux=0 apparmor=0 nospectre_v2 l1tf=off no_stf_barrier
    nospec_store_bypass_disable noibrs noibpb spectre_v2_user=off
    transparent_hugepage=never elevator=cfq pcie_aspm=powersave
    mitigations=off nopti=1 pti=off quiet rd.udev.log_priority=3
    vt.global_cursor_default=0 loglevel=0 mitigations=off
    sysrq_always_enabled=1
  Desktop: KDE Plasma 5.24.0 tk: Qt 5.15.2 wm: kwin_x11 vt: 1 dm: startx
    Distro: Garuda Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 81LG v: Lenovo IdeaPad L340-15IWL
    serial: <superuser required> Chassis: type: 10 v: Lenovo IdeaPad L340-15IWL
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: NO DPK serial: <superuser required>
    UEFI: LENOVO v: ATCN45WW date: 05/17/2021
Battery:
  ID-1: BAT0 charge: 37.0 Wh (99.5%) condition: 37.2/36.0 Wh (103.5%)
    volts: 12.7 min: 11.3 model: LGC L18L3PF1 type: Li-poly serial: <filter>
    status: Full cycles: 648
CPU:
  Info: model: Intel Core i5-8265U bits: 64 type: MT MCP
    arch: Comet/Whiskey Lake note: check family: 6 model-id: 0x8E (142)
    stepping: 0xC (12) microcode: 0xEC
  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: 1638 high: 3200 min/max: 400/3900 scaling:
    driver: intel_pstate governor: powersave cores: 1: 797 2: 800 3: 800 4: 800
    5: 1434 6: 2211 7: 3067 8: 3200 bogomips: 28800
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: itlb_multihit status: KVM: Vulnerable
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: spec_store_bypass status: Vulnerable
  Type: spectre_v1 status: Vulnerable: __user pointer sanitization and
    usercopy barriers only; no swapgs barriers
  Type: spectre_v2 status: Vulnerable, IBPB: disabled, STIBP: disabled
  Type: srbds mitigation: TSX disabled
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel WhiskeyLake-U GT2 [UHD Graphics 620] vendor: Lenovo
    driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:3ea0 class-ID: 0300
  Device-2: IMC Networks Integrated Camera type: USB driver: uvcvideo
    bus-ID: 1-7:3 chip-ID: 13d3:5a08 class-ID: 0e02 serial: <filter>
  Display: server: X.Org 1.21.1.3 compositor: kwin_x11 driver:
    loaded: intel unloaded: modesetting alternate: fbdev,vesa display-ID: :0
    screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2")
    s-diag: 582mm (22.9")
  Monitor-1: eDP1 res: 1920x1080 hz: 60 dpi: 143
    size: 340x190mm (13.4x7.5") diag: 389mm (15.3")
  OpenGL: renderer: Mesa Intel UHD Graphics 620 (WHL GT2)
    v: 4.6 Mesa 21.3.5 direct render: Yes
Audio:
  Device-1: Intel Cannon Point-LP High Definition Audio vendor: Lenovo
    driver: snd_hda_intel v: kernel
    alternate: snd_soc_skl,snd_sof_pci_intel_cnl bus-ID: 00:1f.3
    chip-ID: 8086:9dc8 class-ID: 0403
  Sound Server-1: ALSA v: k5.16.8-zen1-1-zen running: yes
  Sound Server-2: PulseAudio v: 15.0 running: no
  Sound Server-3: PipeWire v: 0.3.45 running: yes
Network:
  Device-1: Intel Cannon Point-LP CNVi [Wireless-AC] driver: iwlwifi
    v: kernel bus-ID: 00:14.3 chip-ID: 8086:9df0 class-ID: 0280
  IF: wlp0s20f3 state: up mac: <filter>
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Lenovo driver: r8169 v: kernel port: 3000 bus-ID: 01:00.0
    chip-ID: 10ec:8168 class-ID: 0200
  IF: enp1s0 state: down mac: <filter>
Bluetooth:
  Device-1: Intel Bluetooth 9460/9560 Jefferson Peak (JfP) type: USB
    driver: btusb v: 0.8 bus-ID: 1-10:5 chip-ID: 8087:0aaa class-ID: e001
  Report: bt-adapter ID: hci0 rfk-id: 3 state: down
    bt-service: enabled,running rfk-block: hardware: no software: no
    address: <filter>
Drives:
  Local Storage: total: 1.14 TiB used: 866.71 GiB (74.1%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: SK Hynix
    model: HFM256GDHTNG-8310A size: 238.47 GiB block-size: physical: 512 B
    logical: 512 B speed: 15.8 Gb/s lanes: 2 type: SSD serial: <filter>
    rev: 80060C00 temp: 35.9 C scheme: MBR
  ID-2: /dev/sda maj-min: 8:0 vendor: Western Digital
    model: WDS500G2B0A-00SM50 size: 465.76 GiB block-size: physical: 512 B
    logical: 512 B speed: 6.0 Gb/s type: SSD serial: <filter> rev: 30WD
    scheme: MBR
  ID-3: /dev/sdb maj-min: 8:16 vendor: Toshiba model: MQ01ABF050
    size: 465.76 GiB block-size: physical: 4096 B logical: 512 B
    speed: 6.0 Gb/s type: HDD rpm: 5400 serial: <filter> rev: 4C scheme: GPT
Partition:
  ID-1: / raw-size: 39.8 GiB size: 39.8 GiB (100.00%) used: 19.04 GiB (47.9%)
    fs: btrfs dev: /dev/sda4 maj-min: 8:4
  ID-2: /boot/efi raw-size: 513 MiB size: 512 MiB (99.80%)
    used: 6.9 MiB (1.3%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 39.8 GiB size: 39.8 GiB (100.00%)
    used: 19.04 GiB (47.9%) fs: btrfs dev: /dev/sda4 maj-min: 8:4
  ID-4: /var/log raw-size: 39.8 GiB size: 39.8 GiB (100.00%)
    used: 19.04 GiB (47.9%) fs: btrfs dev: /dev/sda4 maj-min: 8:4
  ID-5: /var/tmp raw-size: 39.8 GiB size: 39.8 GiB (100.00%)
    used: 19.04 GiB (47.9%) fs: btrfs dev: /dev/sda4 maj-min: 8:4
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 19.42 GiB used: 0 KiB (0.0%) priority: 100
    dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 38.0 C pch: 37.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 282 Uptime: 26m wakeups: 7892 Memory: 19.42 GiB
  used: 8.32 GiB (42.8%) Init: systemd v: 250 target: multi-user.target
  tool: systemctl Compilers: gcc: 11.1.0 clang: 13.0.1 Packages: pacman: 1432
  lib: 367 Shell: Bash v: 5.1.16 running-in: konsole inxi: 3.3.12
Garuda (2.5.4-2):
  System install date:     2022-02-11
  Last full system update: 2022-02-12
  Is partially upgraded:   No
  Relevant software:       NetworkManager
  Windows dual boot:       No/Undetected
  Snapshots:               Snapper
  Failed units:

btw why i dont like to restart plasmashell is 'cause it causes dolphin to crash, especially if there is a copying process. another issue i would like to solve.

my /usr/lib/systemd/system-sleep/ is empty and /etc/systemd/sleep.conf only contains comments. everything is on default.

I would probably suspect a power-saving feature doing this. That's what I'd research first.

i dont know what do you actually mean by power-saving feature, sorry.
but what i did is i disabled everything in garuda assistant > settings > power save tweaks and then rebooted. no result, widget still stops working on resume.

SOLVED!
and i honestly dont know why this works, actually it even should not, but the solution is
add sudo systemctl stop bluetooth either to resume target of systemd, or (which i did) right into hotkey after the actual suspend command (like `systrmctl suspend ; sleep 5 ; sudo systemctl stop bluetooth)
it now leaves the bluetooth disabled after resume but widget does not stop working

notice that im using sudo without password on my system and otherwise it would not work if your sudo asks for a password.

Nah, I’m thinking a simple modprobe.d configuration file entry would do.

That’s not the way to do things. That hacky shit presents an extreme security risk, and neither you nor I know just exactly what they are.

If I'd seen your post earlier I could have saved you some effort. The usual way this is corrected is by writing a service to stop bluetooth before suspending, then restarting it after resume.

Your method while it works, may be overwritten in the future by an update (unless you used a systemd override file). It is best not to modify the actual system service itself.

@Bro already covered why it is not a good idea to remove the password prompt from sudo for your other fix.

3 Likes

well, as you may see by my inxi im not a security fan, i prefer speed, performance and comfort. imho security on localhost is not important until you try out some viruses or whatever. of course i will change my opinion if i’d be hacked but it’s like 4 years so far of using sudo without password, chmod -R a+w /usr/* and other security risks that just saves time.

but yes, you might just do suid bit for systemctl or something.
or call it with pkexec so you would have to enter your password on resume every time, but that is so secure XD

actually you can't disable bluetooth since it just instantly restarts itself and appears in tray again after less than a second, sometimes not even disabled
and sometimes it does not until you restart plasmashell but it's enabled anyway

Really, well I'll have to inform all the users I've written successful bluetooth suspend services for to quit using them as you've informed us this does not work. :stuck_out_tongue_winking_eye:

1 Like

i'm trying systemctl stop bluetooth only. maybe i should do bluetooth.socket or whatever?
and i thought it restarts automatically because it crashes fairly often. like every third time i disconnect my headphones it crashes and then appears again
so i need to systemctl disable bluetooth ; systemctl stop bluetooth to just stop it and then enable and start to run. :confused:

Search and Yee shall find:

Change the entries from hibernate to sleep in the service.

2 Likes

thanks, that solved my problem (even though it would be much easier and even faster to just disable+stop and then enable+start...)
but now suspend takes a lot of time which is kind of annoying so i have do edit my sleep hotkey cmd anyways. dirty hack is xbacklight -s 0 -t 0 ; systemctl suspend ; sleep 2 or so idk ; xbacklight -s 100 -t 0 this makes it look like suspend is instant xd

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.