Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: Arch: met udev rule voor add werkt, maar remove action niet.  (gelezen 490 keer)

Offline bart85

  • Lid
Arch: met udev rule voor add werkt, maar remove action niet.
« Gepost op: 2023/01/31, 10:46:25 »
https://gitlab.com/kingsindian85/creative-ideas/-/blob/main/soundvolume.sh

Bovenstaand script werkt, maar 2x bluetoothctl oproepen is overbodig.
Ik wil een environment variable instellen met een udev rule. Bij het aankoppelen van mijn bluetooth speaker wil ik die variable instellen en systemwide is op te vragen. Globaal is dat onderstaand maar moet nog aangepast worden.
ACTION=="add", SUBSYSTEM=="bluetooth", ATTRS{address}=="xx:xx:xx:xx:xx:xx", RUN+="???"
Hoe stel ik een variabele in met udev? Waarbij de variabele het Mac address bevat.

*Het zou ook kunnen met:
+RUN="/bin/bash -c ' echo xx > /tmp/bt_speaker'"En bij remove het aangemaakte bestand weer verwijderen.
« Laatst bewerkt op: 2023/01/31, 17:53:54 door bart85 »
Relying on complex tools to manage and build your system is going to hurt the end-users. [...] "If you try to hide the complexity of the system, you'll end up with a more complex system". Layers of abstraction that serve to hide internals are never a good thing. Instead, the internals should be designed in a way such that they NEED no hiding.

— Aaron Griffin

Offline bart85

  • Lid
Re: Arch: met udev rule variabele systemwide instellen?
« Reactie #1 Gepost op: 2023/01/31, 14:45:59 »
De udev rules en ook aanpassingen werkt niet.
Relying on complex tools to manage and build your system is going to hurt the end-users. [...] "If you try to hide the complexity of the system, you'll end up with a more complex system". Layers of abstraction that serve to hide internals are never a good thing. Instead, the internals should be designed in a way such that they NEED no hiding.

— Aaron Griffin

Offline bart85

  • Lid
Re: Arch: met udev rule variabele systemwide instellen?
« Reactie #2 Gepost op: 2023/01/31, 15:44:02 »
ACTION=="add", SUBSYSTEM=="input", ATTR{name}=="JBL Charge Essential (AVRCP)", RUN+="/root/btspeaker.add"
ACTION=="remove", SUBSYSTEM=="input",  ATTR{name}=="JBL Charge Essential (AVRCP)", RUN+="/root/btspeaker.remove"

Dit is de nieuwe regel. Bij het toevoegen werkt het. De remove action werkt niet.
Relying on complex tools to manage and build your system is going to hurt the end-users. [...] "If you try to hide the complexity of the system, you'll end up with a more complex system". Layers of abstraction that serve to hide internals are never a good thing. Instead, the internals should be designed in a way such that they NEED no hiding.

— Aaron Griffin

Offline bart85

  • Lid
Re: Arch: met udev rule voor add werkt, maar remove action niet.
« Reactie #3 Gepost op: 2023/02/01, 17:40:21 »
https://gitlab.com/kingsindian85/creative-ideas/-/blob/main/sndvol.sh

Udev rule maakt nu een symlink aan ipv een script uitvoeren. Mijn programma kan nu via de symlink zien of speaker verbonden is. Bij afkoppelen word de symlink weer verwijderd. Een remove action is nu overbodig.
Script op gitlab kan volume aanpassen voor zowel gewone speakers als bluetooth speakers. Nodig voor de configuratie van sway.
Opgelost
« Laatst bewerkt op: 2023/02/01, 18:11:26 door bart85 »
Relying on complex tools to manage and build your system is going to hurt the end-users. [...] "If you try to hide the complexity of the system, you'll end up with a more complex system". Layers of abstraction that serve to hide internals are never a good thing. Instead, the internals should be designed in a way such that they NEED no hiding.

— Aaron Griffin