Page 1 of 4 123 ... LastLast
Results 1 to 10 of 33

Thread: Disable optical sound line on MacBook Pros

  1. #1
    Join Date
    Jun 2020
    Location
    France
    Posts
    56

    Lightbulb Disable optical sound line on MacBook Pros

    Each time I booted in openSUSE, the digital optical line was activated (output of red light from the mini jack port), so after some google searchs, I've found how to disable this with the help of ALSA:


    1. Fire up a root shell and launch alsamixer(1)
    2. Use the arrow keys to move around and when over S/PDIF press M to mute (if there's more than one S/PDIF lines cycle mute through each of those until this turns off the light)
    3. Hit the Escape key - DO NOT CLOSE TERMINAL
    4. Type `sudo alsactl store -f /var/lib/alsa/asound.state` - This will make it persist across reboots
    5. Close the shell
    openSUSE Tumbleweed / xfce 4.16 on:
    MBPs mid-2012 /late-2006/mid-2015


  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    28,745

    Default Re: Disable optical sound line on MacBook Pros

    A minor remark/question.

    Why do you use sudo in #4 when you already fired up a root shell in #1?
    Henk van Velden

  3. #3
    Join Date
    Jun 2020
    Location
    France
    Posts
    56

    Default Re: Disable optical sound line on MacBook Pros

    Nice catch! Thanks
    Its a typo, call to sudo(8) isn't needed
    openSUSE Tumbleweed / xfce 4.16 on:
    MBPs mid-2012 /late-2006/mid-2015


  4. #4
    Join Date
    Jun 2020
    Location
    France
    Posts
    56

    Lightbulb Re: Disable optical sound line on MacBook Pros

    Unfortunately, calling alsamixer(1) from a root shell or with sudo(8) doesn't work anymore on openSUSE Tumbleweed (20201119 snapshot here) so as a workaround I've created the following .desktop file to autostart from your DE a call to alsactl(1):

    Code:
    alsactl --file ~/.config/asound.state store
    Create with your favorite editor the alsarestore.desktop file:

    Code:
    vim ~/.config/autostart/alsarestore.desktop
    with the following content:

    Code:
    [Desktop Entry]
    Type=Application
    Terminal=false
    Name=alsarestore
    Exec=bash -c 'sleep 15 ; alsactl --file ~/.config/asound.state restore'
    openSUSE Tumbleweed / xfce 4.16 on:
    MBPs mid-2012 /late-2006/mid-2015


  5. #5
    Join Date
    Jun 2020
    Location
    France
    Posts
    56

    Default Re: Disable optical sound line on MacBook Pros

    Another cleaner way of disabling at boot the S/PDIF on MacBook Pros running Tumbleweed and globally is making systemd(1) handles this with a help of a new service and timer as by default alsa tries to restore /var/lib/alsa/asound.state before the sound card driver is entirely loaded by the kernel.

    On a root shell:
    1. Create a new systemd service "/etc/systemd/system/alsa-restore-delayed.service" with the following content after disabling the S/PDIF output (see my first message of this tread):

    Code:
    [Unit]
    Description=Delayed Restore Sound Card State 
    ConditionPathExists=!/etc/alsa/state-daemon.conf
    ConditionPathExistsGlob=/dev/snd/control*
    ConditionPathExists=/var/lib/alsa/asound.state
    
    [Service]
    Type=oneshot
    ExecStart=-/usr/sbin/alsactl restore
    2. Create a systemd timer "/etc/systemd/system/alsa-restore-delayed.timer" with the following content:

    Code:
    [Unit]
    Description=Timer Delayed Restore Sound Card State
    
    [Timer]
    OnBootSec=30
    3. Add the timer at multi-user.target:

    Code:
    systemctl add-wants multi-user.target alsa-restore-delayed.timer && systemctl daemon-reload
    Credits goes to user laurent85
    openSUSE Tumbleweed / xfce 4.16 on:
    MBPs mid-2012 /late-2006/mid-2015


  6. #6
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    2,688
    Blog Entries
    1

    Default Re: Disable optical sound line on MacBook Pros

    Quote Originally Posted by Nightstalker View Post
    Another cleaner way of disabling at boot the S/PDIF on MacBook Pros running Tumbleweed and globally is making systemd(1) handles this with a help of a new service and timer as by default alsa tries to restore /var/lib/alsa/asound.state before the sound card driver is entirely loaded by the kernel.

    On a root shell:
    1. Create a new systemd service "/etc/systemd/system/alsa-restore-delayed.service" with the following content after disabling the S/PDIF output (see my first message of this tread):

    Code:
    [Unit]
    Description=Delayed Restore Sound Card State 
    ConditionPathExists=!/etc/alsa/state-daemon.conf
    ConditionPathExistsGlob=/dev/snd/control*
    ConditionPathExists=/var/lib/alsa/asound.state
    
    [Service]
    Type=oneshot
    ExecStart=-/usr/sbin/alsactl restore
    2. Create a systemd timer "/etc/systemd/system/alsa-restore-delayed.timer" with the following content:

    Code:
    [Unit]
    Description=Timer Delayed Restore Sound Card State
    
    [Timer]
    OnBootSec=30
    3. Add the timer at multi-user.target:

    Code:
    systemctl add-wants multi-user.target alsa-restore-delayed.timer && systemctl daemon-reload
    Credits goes to user laurent85
    openSUSE has its own alsa services:

    Code:
    erlangen:~ # systemctl list-unit-files 'alsa*'               
    UNIT FILE            STATE  VENDOR PRESET
    alsa-restore.service static -            
    alsa-state.service   static -            
    alsasound.service    alias  -            
    
    3 unit files listed. 
    erlangen:~ #
    openSUSE has target:

    Code:
    erlangen:~ # systemctl list-dependencies timers.target             
    timers.target 
     ├─backup-home.timer 
     ├─backup-rpmdb.timer 
     ├─backup-sysconfig.timer 
     ├─btrfs-balance.timer 
     ├─btrfs-defrag.timer 
     ├─btrfs-scrub.timer 
     ├─btrfs-trim.timer 
     ├─fstrim.timer 
     ├─logrotate.timer 
     ├─mandb.timer 
     ├─mlocate.timer 
     ├─packagekit-background.timer 
     ├─snapper-cleanup.timer 
     ├─snapper-timeline.timer 
     └─systemd-tmpfiles-clean.timer 
    erlangen:~ #
    Timers have an install section:

    Code:
    [Install] 
    WantedBy=timers.target
    You may try to use vendor versions of alsa services.
    AMD Athlon 4850e (2009), openSUSE 13.1, KDE 4, Intel i3-4130 (2014), i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), openSUSE Tumbleweed, KDE Plasma 5

  7. #7
    Join Date
    Jun 2020
    Location
    France
    Posts
    56

    Default Re: Disable optical sound line on MacBook Pros

    Thanks for your inputs. However none of the default timer and systemd services bundled with Tumbleweed works with these laptops.
    The S/PDIF is always active despite custom settings set with alsamixer(1) and saved on /var/lib/alsa/asound.state.

    At first view, with none of the workarounds I've made, leaving Tumbleweed doing its stuff, /var/lib/alsa/asound.state is reseted at each boot no matter what custom settings are saved with `alsactl store` on /var/lib/alsa/asound.state.
    From logs, this shows alsa is trying to apply settings before the sound card driver is fully loaded, thus overwriting custom /var/lib/alsa/asound.state with a new one.

    With Leap 15.2, it just works whereas it's not with Tumbleweed snapshots I've tested and actually use, so the last workaround I've posted actually works on all of the MacBook Pros I resurrected thanks to openSUSE
    openSUSE Tumbleweed / xfce 4.16 on:
    MBPs mid-2012 /late-2006/mid-2015


  8. #8
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    2,688
    Blog Entries
    1

    Default Re: Disable optical sound line on MacBook Pros

    Quote Originally Posted by Nightstalker View Post
    At first view, with none of the workarounds I've made, leaving Tumbleweed doing its stuff, /var/lib/alsa/asound.state is reseted at each boot no matter what custom settings are saved with `alsactl store` on /var/lib/alsa/asound.state. From logs, this shows alsa is trying to apply settings before the sound card driver is fully loaded, thus overwriting custom /var/lib/alsa/asound.state with a new one.
    Thanks for the feedback! Are you sure:

    Code:
    erlangen:~ # journalctl -b -1 -u alsa-restore.service  
    -- Logs begin at Sat 2020-11-14 06:05:06 CET, end at Thu 2020-11-26 18:44:19 CET. -- 
    Nov 25 21:05:16 erlangen systemd[1]: Starting Save/Restore Sound Card State... 
    Nov 25 21:05:17 erlangen systemd[1]: Finished Save/Restore Sound Card State. 
    Nov 26 18:42:00 erlangen systemd[1]: Stopping Save/Restore Sound Card State... 
    Nov 26 18:42:00 erlangen systemd[1]: alsa-restore.service: Succeeded. 
    Nov 26 18:42:00 erlangen systemd[1]: Stopped Save/Restore Sound Card State. 
    erlangen:~ # systemctl status alsa-restore.service 
     alsa-restore.service - Save/Restore Sound Card State 
         Loaded: loaded (/usr/lib/systemd/system/alsa-restore.service; static) 
         Active: active (exited) since Thu 2020-11-26 18:42:37 CET; 5min ago 
        Process: 763 ExecStart=/usr/sbin/alsactl restore (code=exited, status=0/SUCCESS) 
       Main PID: 763 (code=exited, status=0/SUCCESS) 
    
    Nov 26 18:42:37 erlangen systemd[1]: Starting Save/Restore Sound Card State... 
    Nov 26 18:42:37 erlangen systemd[1]: Finished Save/Restore Sound Card State. 
    erlangen:~ #
    
    Did you check conditions?

    Code:
    erlangen:~ # systemctl cat alsa-restore.service    
    # /usr/lib/systemd/system/alsa-restore.service
    # 
    # Note that two different ALSA card state management schemes exist and they 
    # can be switched using a file exist check - /etc/alsa/state-daemon.conf . 
    # 
    
    [Unit] 
    Description=Save/Restore Sound Card State 
    ConditionPathExists=!/etc/alsa/state-daemon.conf 
    ConditionPathExistsGlob=/dev/snd/control* 
    ConditionPathExists=/var/lib/alsa/asound.state 
    
    [Service] 
    Type=oneshot 
    RemainAfterExit=true 
    ExecStart=-/usr/sbin/alsactl restore 
    ExecStop=-/usr/sbin/alsactl store 
    erlangen:~ #
    
    
    
    AMD Athlon 4850e (2009), openSUSE 13.1, KDE 4, Intel i3-4130 (2014), i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), openSUSE Tumbleweed, KDE Plasma 5

  9. #9
    Join Date
    Jun 2020
    Location
    France
    Posts
    56

    Default Re: Disable optical sound line on MacBook Pros

    Quote Originally Posted by karlmistelberger View Post
    Thanks for the feedback! Are you sure:
    You're welcome
    Yes (do note on the following output I have disabled alsa-restore.service but still having the same output if /etc/alsa/state-daemon.conf is there and this service is enabled):

    Code:
    root@raiatea:/home/matt # journalctl -b -1 -u alsa-restore.service 
    -- Logs begin at Sun 2020-11-22 13:30:29 CET, end at Fri 2020-11-27 02:48:05 CET. --
    nov. 26 15:46:14 raiatea systemd[1]: Starting Save/Restore Sound Card State...
    nov. 26 15:46:14 raiatea systemd[1]: Finished Save/Restore Sound Card State.
    nov. 27 02:10:49 raiatea.local systemd[1]: Stopping Save/Restore Sound Card State...
    nov. 27 02:10:49 raiatea.local systemd[1]: alsa-restore.service: Succeeded.
    nov. 27 02:10:49 raiatea.local systemd[1]: Stopped Save/Restore Sound Card State.
    root@raiatea:/home/matt # systemctl status alsa-restore.service    
    ● alsa-restore.service - Save/Restore Sound Card State
         Loaded: loaded (/usr/lib/systemd/system/alsa-restore.service; static)
         Active: inactive (dead)
      Condition: start condition failed at Fri 2020-11-27 02:11:07 CET; 38min ago
                 └─ ConditionPathExistsGlob=/dev/snd/control* was not met
    
    nov. 27 02:11:07 raiatea systemd[1]: Condition check resulted in Save/Restore Sound Card State being skipped.
    root@raiatea:/home/matt # 
    Quote Originally Posted by karlmistelberger View Post
    Did you check conditions?
    Also yes:

    Code:
    root@raiatea:/home/matt # systemctl cat alsa-restore.service
    # /usr/lib/systemd/system/alsa-restore.service
    #
    # Note that two different ALSA card state management schemes exist and they
    # can be switched using a file exist check - /etc/alsa/state-daemon.conf .
    #
    
    [Unit]
    Description=Save/Restore Sound Card State
    ConditionPathExists=!/etc/alsa/state-daemon.conf
    ConditionPathExistsGlob=/dev/snd/control*
    ConditionPathExists=/var/lib/alsa/asound.state
    
    [Service]
    Type=oneshot
    RemainAfterExit=true
    ExecStart=-/usr/sbin/alsactl restore
    ExecStop=-/usr/sbin/alsactl store
    root@raiatea:/home/matt # 
    Why one of alsa-restore.service's condition is not met puzzle me and lead me to think that the sound card driver isn't fully loaded before the service is run. On Leap 15.2 no such problem after muting the S/PDIF in alsamixer(1).
    openSUSE Tumbleweed / xfce 4.16 on:
    MBPs mid-2012 /late-2006/mid-2015


  10. #10
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    2,688
    Blog Entries
    1

    Default Re: Disable optical sound line on MacBook Pros

    Quote Originally Posted by Nightstalker View Post
    Why one of alsa-restore.service's condition is not met puzzle me and lead me to think that the sound card driver isn't fully loaded before the service is run. On Leap 15.2 no such problem after muting the S/PDIF in alsamixer(1).
    What are yours:

    Code:
    erlangen:~ # systemctl list-dependencies alsa-restore.service 
    alsa-restore.service 
     ├─system.slice 
     └─sysinit.target 
       ├─dev-hugepages.mount 
       ├─dev-mqueue.mount 
       ├─dracut-shutdown.service 
       ├─haveged.service 
       ├─kmod-static-nodes.service 
       ├─plymouth-read-write.service 
       ├─plymouth-start.service 
       ├─proc-sys-fs-binfmt_misc.automount 
       ├─sys-fs-fuse-connections.mount 
    ●   ├─sys-kernel-config.mount 
       ├─sys-kernel-debug.mount 
       ├─sys-kernel-tracing.mount 
    ●   ├─systemd-ask-password-console.path 
    ●   ├─systemd-binfmt.service 
    ●   ├─systemd-boot-system-token.service 
    ●   ├─systemd-firstboot.service 
    ●   ├─systemd-hwdb-update.service 
    ●   ├─systemd-journal-catalog-update.service 
       ├─systemd-journal-flush.service 
       ├─systemd-journald.service 
    ●   ├─systemd-machine-id-commit.service 
       ├─systemd-modules-load.service 
       ├─systemd-random-seed.service 
       ├─systemd-sysctl.service 
    ●   ├─systemd-sysusers.service 
       ├─systemd-tmpfiles-setup-dev.service 
       ├─systemd-tmpfiles-setup.service 
       ├─systemd-udev-trigger.service 
       ├─systemd-udevd.service 
    ●   ├─systemd-update-done.service 
       ├─systemd-update-utmp.service 
       ├─cryptsetup.target 
       ├─local-fs.target 
       │ ├─-.mount 
       │ ├─\x2esnapshots.mount 
       │ ├─boot-efi.mount 
       │ ├─boot-grub2-i386\x2dpc.mount 
       │ ├─boot-grub2-x86_64\x2defi.mount 
       │ ├─home.mount 
       │ ├─home\x2dSSD.mount 
       │ ├─opt.mount 
       │ ├─root.mount 
       │ ├─srv.mount 
       │ ├─systemd-remount-fs.service 
       │ ├─tmp.mount 
       │ ├─usr-local.mount 
    ●   │ ├─var-lock.mount 
    ●   │ ├─var-run.mount 
       │ └─var.mount 
       └─swap.target 
    erlangen:~ #
    
    
    AMD Athlon 4850e (2009), openSUSE 13.1, KDE 4, Intel i3-4130 (2014), i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), openSUSE Tumbleweed, KDE Plasma 5

Page 1 of 4 123 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •