HDMI-CEC - control brightness - television

is there any way to control TV brightness over HDMI CEC?
I built the TV into a frame and forgot to turn down the brightness...Any chance or would I have to unframe it in order to be able to use the remote?
Commands like echo 'volup' | cec-client -s -d 1 work fine, but is there any way to control the brightness? Maybe by transfering specific bytes?
Thanks in advance!

Have you tried:
echo h | cec-client -s -d 1
Source: https://raspberrypi.stackexchange.com/a/9147

Related

lpr command - how to force black and white?

I have troubles with the LPR command. Before the printer has changed. I ran my instructions using
lpr -P printer_name -o raw file_name
Now I need to run print instructions on the new printer which only accepts black and white printed colors.
After browsing the internet, I found the option saturation=0 but without success.
example : lpr -P printer_name -o saturation=0 -o raw file_name
I have also tried to edit the *DefaultColorModel: CMYK parameter of the ppd file and change it ofr *DefaultColorModel: Gray but it doesn't work either.
By using meld, I compared the .ppd file and printer.conf after printing with my ubuntu and ctrl+P but I don't see anything useful.
Can you help me ? Thanks
Ok, i found the right option.
If you need lock black and white for printing. You need use ColorModel option like this :
lpr -P printer_name -o ColorModel=KGray file_name

Play online Radio Station as a Music on Hold in Asterisk

Is there a way (Tool or any idea) to play radio station (Streamed via IceCast) as a Music On Hold in Asterisk?, I Have a streaming server and Asterisk Server running and working independently very well, only I want to integrate both of two.
Your Help Please, THANKS IN ADVANCE
My OS: Linux - Centos
My Music On Hold Class:
mode=custom
application=/usr/bin/sox mystreamingurl -b 64000 -r 44100 -t ogg -
This script produces upnormal and noisy sound which is totally different from the sound produced by the Streaming Server(IceCas).
Used MPG123 player and worked like a charm
Udated MOH Class:
mode=custom
application=/usr/bin/mpg123 -q -r 8000 -f 8192 --mono -s http://mystreamingurl
Asterisk's internal sound format is 8khz mono PCM
You should directly specify for sox which output format to use for in and out.
Also sox is NOT streaming utility, you should use something like MPlayer.
https://www.voip-info.org/asterisk-config-musiconholdconf/#StreamradiousingMPlayerforMOH
#!/bin/bash
if -n "`ls /tmp/asterisk-moh-pipe.*`" ; then
rm /tmp/asterisk-moh-pipe.*
fi
PIPE="/tmp/asterisk-moh-pipe.$$"
mknod $PIPE p
mplayer http://address_of_radio_station -really-quiet -quiet -ao pcm:file=$PIPE -af resample=8000,channels=1,format=mulaw 2>/dev/null | cat $PIPE 2>/dev/null
rm $PIPE

Determine if app is Wayland or X client

Is there a way to determine if an arbitrary app is an X client or a Wayland client (or neither) from the command line without fully launching it?
You can run ldd on the binary to check which libraries it links against. If it has "libwayland-client" you're probably looking at a Wayland client. For X you need to look for "libX11" or "libxcb".
To expand on the excellent answer given by #Alexander Sukhoverkhov what needs to be done is:
cd /usr/bin
ldd $application_name | grep wayland
Furthermore, to check which binaries have wayland support you could try:
cd /usr/bin
find . | xargs ldd | grep wayland -B 55
The above is not really very clean but it works. You can further pipe it to a file and then use vim to navigate.
cd /usr/bin
find . | xargs ldd | grep wayland -B 55 >> candidates
vim candidates
# Use vi movement
The -B flag stands for before and helps to print the binary name.

Get current playing file in MPlayer slave mode

Problem: I can't find any way to reliably get the current playing file in an MPlayer playlist.
Here is how far I have gotten. This working ash script monitors a text file with the path to the current playlist. When I update the file, the script closes the old instance of MPlayer and opens a new one with the new playlist:
# POLL PLAYLIST FILE FOR CHANGES
CURRENTPLAYLISTPATH=/home/tc/currentplaylist
INFIFO=/tmp/mplayer-in
CURRENTPLAYLIST="NEVERMATCHAPLAYLIST"
FIRSTRUN=1
while [ 1 ];
do
# CHECK FOR NEW PLAYLIST
NEWPLAYLIST=$(head -n 1 $CURRENTPLAYLISTPATH)
if [[ "$NEWPLAYLIST" != "$CURRENTPLAYLIST" ]]; then
if [ "$FIRSTRUN" == 0 ]; then
echo "quit" > "$INFIFO"
fi
# CREATE NAMED PIPE, IF NEEDED
trap "rm -f $INFIFO" EXIT
if [ ! -p $INFIFO ]; then
mkfifo $INFIFO
fi
# START MPLAYER
mplayer -fixed-vo -nolirc -vc ffmpeg12vdpau,ffh264vdpau, -playlist $NEWPLAYLIST -loop 0 -geometry 1696x954 -slave -idle -input file=$INFIFO -quiet -msglevel all=0 -identify | tee -a /home/tc/mplayer.log &
CURRENTPLAYLIST=$NEWPLAYLIST
FIRSTRUN=0
fi
sleep 5;
done
My original plan was just to use the "-identify" flag and parse the log file. This actually works really well up until I need to truncate the log file to keep it from getting too large. As soon as my truncating script is run, MPlayer stops writing to the log file:
FILENAME=/home/tc/mplayer.log
MAXCOUNT=100
if [ -f "$FILENAME" ]; then
LINECOUNT=`wc -l "$FILENAME" | awk '{print $1}'`
if [ "$LINECOUNT" -gt "$MAXCOUNT" ]; then
REMOVECOUNT=`expr $LINECOUNT - $MAXCOUNT`
sed -i 1,"$REMOVECOUNT"d "$FILENAME"
fi
fi
I have searched and searched but have been unable to find any other way of getting the current playing file that works.
I have tried piping the output to another named pipe and then monitoring it, but only works for a few seconds, then MPlayer completely freezes.
I have also tried using bash (instead of ash) and piping the output to a function like the following, but get the same freezing problem:
function parseOutput()
{
while read LINE
do
echo "get_file_name" > /tmp/mplayer-in
if [[ "$LINE" == *ANS_FILENAME* ]]
then
echo ${LINE##ANS_FILENAME=} > "$CURRENTFILEPATH"
fi
sleep 1
done
}
# START MPLAYER
mplayer -fixed-vo -nolirc -vc ffmpeg12vdpau,ffh264vdpau, -playlist $NEWPLAYLIST -loop 0 -geometry 1696x954 -slave -idle -input file=/tmp/mplayer-in -quiet | parseOutput &
I suspect I am missing something very obvious here, so any help, ideas, points in the right direction would be greatly appreciated.
fodder
Alright then, so I'll post mine too.
Give this one a try (assuming there is only one instance running, like on fodder's machine):
basename "$(readlink /proc/$(pidof mplayer)/fd/* | grep -v '\(/dev/\|pipe:\|socket:\)')"
This is probably the safer way, since the file descriptors might not always be in the same order on all systems.
However, this can be shortened, with a little risk:
basename "$(readlink /proc/$(pidof mplayer)/fd/*)" | head -1
You might probably like to install this, too:
http://mplayer-tools.sourceforge.net/
Well, I gave up on getting the track from MPlayer itself.
My 'solution' is probably too hackish, but works for my needs since I know my machine will only ever have one instance of MPlayer running:
lsof -p $(pidof mplayer) | grep -o "/path/to/my/assets/.*"
If anyone has a better option I'm certainly still interested in doing this the right way, I just couldn't make any of the methods work.
fodder
You can use the run command.
Put this in ~/.mplayer/input.conf:
DEL run "echo ${filename} ${stream_pos} >> /home/knarf/out"
Now if you press the delete key while playing a file it will do what you expect i.e. append the current file playing and the position in the stream to the ~/out file. You can replace echo with your program.
See slave mod docs for more info (Ctrl-F somevar).
About getting properties from MPlayer
I have used a non-elegant solution, but it is working for me.
stdbuf -oL mplayer --slave --input=file=$FIFO awesome_awesome.mp3 |
{
while IFS= read -r line
do
if [[ "${line}" == ANS_* ]]; then
echo "${line#*=}" > ${line%=*} # echo property_value > property_name
fi
done
} &
mplayer_pid=&!
read filename < ./ANS_FILENAME
read timeLength < ./ANS_LENGTH
echo ($timeLength) $filename
and so on..
It is in another proccess, that's why I've used files to bring properties
'stdbuf' is for not to miss anything
I started putting together a bash library to handle tasks like this. Basically, you can accomplish this by dumping the mplayer output to a file. Then you grep that dump for "Playing " and take the last result with tail. This should give you the name of the file that's currently playing or that last finished playing.
Take a look at my bash code. You'll want to modify the playMediaFile function to your needs, but the getMediaFileName function should do exactly what you're asking. You'll find the code on my github.

Check whether iPhone device connected with system from commandline?

One of my requirement is "whether iPhone/iPad connected with system from command line" in my currently developing component. or any other systematic way rather than manual?
Expecting your favorable reply soon. thanks in advance...
sri
On a Mac:
ioreg -w -p IOUSB | grep -w iPad
ioreg -w -p IOUSB | grep -w iPhone
I don't know how an iPod Touch shows up.