how to use console amixer for spdif? - linux

in alsamixer I select s/pdif 1 and unmute this, but in console command "amixer set 'S/PDIF 1' 100% unmute" get error:
amixer: Unable to find simple control 'S/PDIF 1'.

Alsamixer occasionally alters the names of some controls. Try
$ amixer contents
to get a list with the amixer controls, their proper names and their current values.
That will allow you to identify which one is the S/PDIF control. You may have to change that control in alsamixer and check for differences in the amixer contents output before and after to find it.
For example, on my system that control is called IEC958 Playback Switch in amixer.

Related

Automatically use desired monitor and the corresponding audio ouput

I'm using manjaro-linux-i3 with polybar and I'm currently working on my multiple monitor setup.
I have a TV which I normally use with the amplifier it is connected to. In addition I have my desk with a triple monitor setup which I normally use with my headphones for audio output. One of my screens is in portrait orientation which always messes up my login screen.
I'm able to change my audio ouput and my active monitor as I wish. But I want it to be more efficient. At the moment I'm using arandr to change my monitor and pavucontrol to change my audio output when needed.
I want that my login manager(lightdm) is always displayed correctly on my monitors(even on the portrait one).
It would be nice if anybody could give me way how to combine changing monitors and the audio output in one blow. So that I don't have to this every time manually.
I have similar setup and I got everything working what you might want if I understood you corretely.
If you setup everything right, then your loginmanager should always be displayed on the monitor which is active at boot and you can switch your monitors&sink with a simple keybind.
First, you can add a script to lightdm to config your monitors so that everything is displayed correctely. But be aware that a broken script can leed to the effect that your loginmanager won't be loaded correctly (blackscrren).
in /etc/lightdm/lightdm.conf you can define a script at #greeter-setup-script= . Simply uncomment the line and add the path to your script.
An easy way to config your monitors the way you want is to use arandr. Simply config your monitor the ways you want and save the setup. You will be saving an usual xrandr command, which can be used in your script.
Here is my script.
It is very basic and actually only checks if a monitor of my desk is active. If so, it initialises the monitors of my desk. If not, it initialises my tv. It also sets the audio output I use with those monitors.
To get a list of all active monitors use this command:
xrandr --listactivemonitors | awk '!/Monitors/ {print $4}'
To get a list off all sinks(audio output) use this command:
pacmd list-sinks | grep -e 'name:' -e 'index:' | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}'
Now you can change my commands (sink and monitor names) with the onces you need. You can execute the script in the terminal so get feedback of the choosen sink and monitor (for testing). Don't forget to make your script executable else it won't work.
I got a similar script to manually change between my tv and my desk (mirroring scrrens, duplicate, tv-only, ect)
It too changes the sink according to the selected monitors. As you are using polybar too, you might notice that I relaunch polybar with sh /home/lluks/.config/polybar/launch.sh This is the script.
It ensures that my applets are displayed on the main monitor as poylbar can only display them on one monitor. This is archieved by using a 2 diffrent bars for poylbar.
For this script to work, you need dmenu and rofi. If I remember corretely, you also need Font Awesome for the icons.

Pacmd command to mute all, open a sound file, then unmute all

I'm an arch linux user and I had a dream. Make a keyboard shortcut that will play a rimshot (Ba Dum Tsssss) when pressed.
After some researches it appears that pacmd is the best option to do so, but I have no idea how it works and the man page is empty, and the help lacks clear information... sinks, modules and sources... well, that's all obscure.
Can anybody help me to achieve my goal ?
From the man page:
pacmd set-sink-mute <index> <1|0>
controls the mute-ness of a given sink (sound interface) where <index> is the sink index (listed with pacmd list-sinks) and 1 or 0 indicates muted or not muted, respectively.
You'll likely want to create a short Bash script that would unmute the sink, play your sound, and then remute it; you can then bind this to a key.

From where alsa getting their default states?

I am trying to get knowledge on alsa. When I saw it, it is automatically storing the previous states of the mixer controls and restoring them in the reboots. So I commented this process from the files /etc/init/alsa-restore.conf /etc/init/alsa-store.conf . After that I make one control to True and rebooted my system. After rebooting I checked the value of the control which is false now.
From where alsa get that control value as false after reboot.
There is no file /var/lib/alsa/asound.state because I removed it.
The initial state of mixer controls is determined either by the driver or by the device itself.
Furthermore, when asound.state does not yet exist, many distributions will call alsactl init.
If you want a mixer control to have a specific value, you must set this value somehow.
If you don't want to rely on asound.state, you could run your own script that sets the control with amixer.
To edit alsamixer settings in linux
use command:
$ alsamixer
just type alsamixer to open alsamixer in terminal

Using different console for respawn process in inittab on embedded device

I am connected on my embedded device with the serial port and would like to start my custom binaries on boot and be able to see the output generated.
My /etc/inittab file contains:
console::respawn:/sbin/getty -L 115200 ttyAPP3 vt100
console::respawn:/usr/bin/mybinary
With this configuration, I can see the output of mybinary in the serial console but It is difficult/impossible to connect (insert login and password) to getty because of the interference of the output generated.
I tried to switch the output in inittab to another not used tty (tty10) like this:
console::respawn:/sbin/getty -L 115200 ttyAPP3 vt100
tty10::respawn:/usr/bin/mybinary
And now I can connect but how can I see the output generated to /dev/tty10 ?
I tried cat /dev/tty10 but nothing is shown.
I know the question is old, but it has no answers at all for crying out loud.
Remember that a TTY is both an output device and also an input device -- by cat'ing from it you're reading input from the terminal which means the keyboard, NOT the screen.
I don't know if there's a parallel in other *nixes, but Linux systems have /dev/vcsX and /dev/vcsaX character devices (nodes c,7,0+X and c,7,128+X respectively) for each /dev/ttyX device - these are mirrors of the data currently on the output of the TTY device (ie. the screen part of the TTY, not the keyboard part). These will give you what you're looking for. The vcsaX devices will give you a displaybyte+attributebyte pair (i.e. the foreground/background text colour -- see other references for more information on text attribute bytes) for each character on the screen, while the vcsX devices give only the displaybyte for each character. Of course it's a raw stream/dump so if the row and/or column count of your terminal doesn't match that of the the TTY you're dumping then you'll need to parse the data and reformat it to match.
tl;dr: use "cat /dev/vcs10"
Hope that helps.

How to select the output device of audio in ubuntu manually?

In Ubuntu, we can select the output device of audio in sound preferences. But now I want to write a shell script, so I need to select the output device from the commandline.
You can first view your current default audio device by typing:
pactl stat
And with
pactl list
you can view all your devices.
And with this command
echo "set-default-sink alsa_output.Headset" | pacmd
you can set the default device.
But I found a much better source for this problem and a included little shell script for this problem here http://ubuntuforums.org/archive/index.php/t-1370383.html

Resources