Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[TIP] Comandare ALSA con i tasti multimediali
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
mouser
Veteran
Veteran


Joined: 10 Aug 2004
Posts: 1419
Location: Milano

PostPosted: Wed Feb 14, 2007 11:27 am    Post subject: [TIP] Comandare ALSA con i tasti multimediali Reply with quote

Ciao a tutti.

Che dire, oggi sono stra produttivo.
Ecco come poter comandare il nostro mixer con i tasti multimediali della tastiera e, perchè no, anche avendo a video una barra di scorrimento che ci indichi come siamo messi in percentuale con l'audio.

Prima di tutto installiamo i programmi che ci servono:
Code:
# emerge -av xbindkeys xosd alsa-utils


Terminata questa operazione, semplicemente, scarichiamo questo script e copiamolo dove sia eseguibile.
Code:
# wget http://mouser.altervista.org/software/gentoo/volume-osd
# chmod +x volume-osd
# chown root:root volume-osd
# mv volume-osd /usr/bin/


Fatto questo lanciamo xbindkeys per leggere quali tasti sono bindati con i controlli di aumento/riduzione/muto del volume
Code:
$ touch ~/.xbindkeysrc && xbindkeys -k


Dopodichè associamo ad ogni tasto un'azione dello script precedentemente scarricato. Il mio .xbindkeysrc è così:
Code:
$ cat ~/.xbindkeysrc
"/usr/bin/volume-osd -"
    m:0x0 + c:174

"/usr/bin/volume-osd +"
    m:0x0 + c:176

"/usr/bin/volume-osd"
    m:0x0 + c:160

Come si capisce, ho i controlli per diminuire, aumentare e togliere/mettere il volume.

Rilanciamo xbindkeys per attivare questi bind
Code:
$ pkill xbindkeys && xbindkeys


E vuallà

Ciriciao
mouser :wink:
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2489
Location: イタリアのロディで

PostPosted: Wed Feb 14, 2007 12:31 pm    Post subject: Reply with quote

Ciao mouser :P
Io ho sempre avuto il problema che se riavvio con muto attivo, al riavvio il bottone non disattiva più il muto.
Speriamo che con il tuo aiuto il problema si risolva.
Stasera a casa ci provo.
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Wed Feb 14, 2007 6:03 pm    Post subject: Reply with quote

Bello.
Però mi sento di consiliare anche lineakd e affini (con supporto osd, ovviamente), lo uso da tanto sul mio Dell e anche se ho dovuto riscrivere la configurazione a mano perchè non presente nel file di default il mio modello sono super-soddisfatto.
A voi l'ardua scelta...
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Wed Feb 14, 2007 6:38 pm    Post subject: Reply with quote

skypjack wrote:
Bello.
Però mi sento di consiliare anche lineakd e affini (con supporto osd, ovviamente), lo uso da tanto sul mio Dell e anche se ho dovuto riscrivere la configurazione a mano perchè non presente nel file di default il mio modello sono super-soddisfatto.
A voi l'ardua scelta...


cosa aspetti a postare la tua conf :D:D:D?


ho un dell... ed uso questo .Xmodmap:

Code:

keycode 160 = XF86AudioMute
keycode 174 = XF86AudioLowerVolume
keycode 176 = XF86AudioRaiseVolume
keycode 162 = XF86AudioPlay
keycode 144 = XF86AudioPrev
keycode 153 = XF86AudioNext
keycode 164 = XF86AudioStop
keycode 209 = XF86Eject




ciao
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Wed Feb 14, 2007 6:56 pm    Post subject: Reply with quote

Bene.
Ti posto entrambi i file.
Questo è /etc/lineakkb.def (in realtà, solo la parte relativa al mio Inspiron 640m della Dell):
Code:
# LinEAK - Linux Support for Easy Access and Internet Keyboards
#  Copyright (C) 2001,2002 Mark Smulders <Mark@PIRnet.nl>
#       and Sheldon Lee-Wen <leewsb@hotMail.com>
#
# Keyboard definition file:
#   This file defines the extra keys of the keyboard types,
#   and the corresponding keycode.
#
# If your keyboard is not in here, please send me an e-Mail so
# I can add Support for it.
#
# WARNING: This definition file is NOT compatible with
#          Lineakd 0.1 and 0.2
#          Lineakconfig 0.1

# [ ... ]

# Ma come, e il mio Dell Inspiron 640m ve lo siete dimenticati? SGRUNF!!
# Aggiungo qualche bella modifica integrativa!! ;)
[DELL-640M]
   brandname   =   "Dell"
   modelname   =   "Dell Inspiron 640m"
    [KEYS]
   # Tasti Multimediali (MediaDirect ovviamente non funziona!!)
      AudioMute      =   160
      AudioNext      =   153
      AudioPlay|Pause      =   162
      AudioPrev      =   144
      AudioStop      =   164
      AudioLowerVolume   =   174
      AudioRaiseVolume   =   176
   # Tasti tastiera extra (vari ed eventuali)
      WinKey         =   115
  [END KEYS]
[END DELL-640M]


E questo è /etc/lineak/lineakd.conf (xbill non può mancare!):
Code:
# LinEAK - Linux support for Easy Access and Internet Keyboards
#  Copyright (c) 2001,2002, 2003  Sheldon Lee Wen <leewsb@hotmail.com>
#     and Mark Smulders <Mark@PIRnet.nl>
#  http://lineak.sourceforge.net
#
# lineakd configuration file
#
# example key configuration:
#    play   = "xmms --play-pause"
#    eject   = EAK_EJECT
#
# Lineakd supports the following modifier keys:
#    control alt shift mod2 mod3 mod4 mod5

CdromDevice = /dev/cdrom
Display_align = center
Display_color = 0aff00
Display_font = -adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-*-*
Display_hoffset = 0
Display_plugin = internal
Display_pos = bottom
Display_soffset = 1
Display_timeout = 3
Display_voffset = 50
KeyboardType = DELL-640M
MixerDevice = /dev/mixer
RAWCommands =
Screensaver =
conffilename = /etc/lineak/lineakd.conf
keystate_capslock =
keystate_numlock =
keystate_scrolllock =

Display_plugin = xosd

AudioLowerVolume = EAK_VOLDOWN
AudioRaiseVolume = EAK_VOLUP
AudioMute = EAK_MUTE
AudioNext = audacious -f
AudioPlay|Pause = audacious -t
AudioPrev = audacious -r
AudioStop = audacious -s
WinKey = /usr/games/bin/xbill


L'unico tasto ignorato è il MediaDirect.
Spero di esserti stato d'aiuto.
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Wed Feb 14, 2007 8:46 pm    Post subject: Reply with quote

skypjack wrote:

L'unico tasto ignorato è il MediaDirect.
Spero di esserti stato d'aiuto.


MediaDirect ha keycode 187

ciao
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2489
Location: イタリアのロディで

PostPosted: Wed Feb 14, 2007 9:23 pm    Post subject: Reply with quote

bandreabis wrote:
Ciao mouser :P
Io ho sempre avuto il problema che se riavvio con muto attivo, al riavvio il bottone non disattiva più il muto.
Speriamo che con il tuo aiuto il problema si risolva.
Stasera a casa ci provo.


PERFETTO! Funziona.
Grazie mouser.
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
mouser
Veteran
Veteran


Joined: 10 Aug 2004
Posts: 1419
Location: Milano

PostPosted: Thu Feb 15, 2007 8:38 am    Post subject: Reply with quote

bandreabis wrote:
PERFETTO! Funziona.
Grazie mouser.


Bene!!!

Ciriciao
mouser :wink
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Thu Feb 15, 2007 7:09 pm    Post subject: Reply with quote

[quote="comio"]
skypjack wrote:
MediaDirect ha keycode 187

In reltà sul mio Inspiron 640m il MediaDirect non da segni di vita, testato sotto xev...
Come hai ricavato quel codice?
Appena posso lo provo, ma non credo che otterrò risultati, quel tasto mi risulta da associare ancora e non ho voglia di farlo...
Almeno finchè non ne ho necessità!!
Ciauz...
Back to top
View user's profile Send private message
flocchini
Veteran
Veteran


Joined: 17 May 2003
Posts: 1124
Location: Milano, Italy

PostPosted: Thu Feb 15, 2007 7:59 pm    Post subject: Reply with quote

[quote="skypjack"]
comio wrote:
skypjack wrote:
MediaDirect ha keycode 187

In reltà sul mio Inspiron 640m il MediaDirect non da segni di vita, testato sotto xev...
Come hai ricavato quel codice?


io con i dell non c'entro un tubo, ma anche io ho un tasto della mia tastiera logitech che sotto xev non da' segni di vita (tutti gli altri si'), se scoprite come rianimarlo mi farebbe comodo (e' il tasto x l'istant messenger azz)
_________________
~~ Per amore della rosa si sopportano le spine... ~~
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Thu Feb 15, 2007 8:24 pm    Post subject: Reply with quote

Non vorrei dire cavolate, la questione dei tasti l'ho liquidata molto tempo fa, ma basta scoprire il codice "macchina" e assiociarlo ad un codice "tasto", il che sembra difficile ma è più facile di quanto pensi (cioè, una cavolata se ci sono riuscito io a capirla), a quel punto lo tratti semplicemente ad esempio appunto con lineak (o cosa vuoi tu). Chiaro, no?
Dai, scherzi a parte, se vuoi appena ho un minuto e la mia macchina sotto mano ti faccio sapere... Ora sono su un pc non mio e un pò di corsa...
Ciauz...
Back to top
View user's profile Send private message
comio
Advocate
Advocate


Joined: 03 Jul 2003
Posts: 2191
Location: Taranto

PostPosted: Thu Feb 15, 2007 8:52 pm    Post subject: Reply with quote

[quote="flocchini"]
skypjack wrote:
comio wrote:
skypjack wrote:
MediaDirect ha keycode 187

In reltà sul mio Inspiron 640m il MediaDirect non da segni di vita, testato sotto xev...
Come hai ricavato quel codice?


io con i dell non c'entro un tubo, ma anche io ho un tasto della mia tastiera logitech che sotto xev non da' segni di vita (tutti gli altri si'), se scoprite come rianimarlo mi farebbe comodo (e' il tasto x l'istant messenger azz)


Molte volte sono visti come tasti del mouse. Io avevo una logitech un po' di tempo fa con un mouse. Alcuni tasti della tastiera erano mappati come tasi del mouse... ho dovuto fare un xconf.org con un mouse a 99 tasti e poi riassegnare le funzioni.

ciao

luigi
_________________
RTFM!!!!

e

http://www.comio.it
:)
Back to top
View user's profile Send private message
flocchini
Veteran
Veteran


Joined: 17 May 2003
Posts: 1124
Location: Milano, Italy

PostPosted: Mon Feb 19, 2007 6:00 pm    Post subject: Reply with quote

skypjack wrote:
basta scoprire il codice "macchina" e assiociarlo ad un codice "tasto", il che sembra difficile ma è più facile di quanto pensi


eh, normalmente quel codice macchina lo hai con xev... se xev non dice nulla che si fa?

@comio: eeeeh?!?! :lol: Come faccio "un mouse a 99 tasti" e soprattutto come gli rimappo le funzioni? :p
_________________
~~ Per amore della rosa si sopportano le spine... ~~
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Mon Feb 19, 2007 8:52 pm    Post subject: Reply with quote

con xev trovi i tasti già associati, non i dissociati... :D
Back to top
View user's profile Send private message
flocchini
Veteran
Veteran


Joined: 17 May 2003
Posts: 1124
Location: Milano, Italy

PostPosted: Mon Feb 19, 2007 10:46 pm    Post subject: Reply with quote

no, con xev trovo un evento che associo ad un keycode che poi associo con xmodmap ad un tasto.

ad esempio, ho mappato 0x1008ff14 con il keycode 162, e poi con xmodmap gli ho assegnato XF86AudioPlay

Code:
KeyRelease event, serial 32, synthetic NO, window 0x3000001,
    root 0x55, subw 0x0, time 3693934252, (93,100), root:(1190,941),
    state 0x10, keycode 162 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False


ora, quando preno il tasto messenger invecenn succede nulla, nessun tipo di output, e io sono fregato :p
_________________
~~ Per amore della rosa si sopportano le spine... ~~
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Tue Feb 20, 2007 12:00 pm    Post subject: Reply with quote

Giusta correzione.
Lo stesso accade per il mio tasto Media Direct, ko.
Se scopri come resuscitarlo, fammi sapere...
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2489
Location: イタリアのロディで

PostPosted: Thu Mar 01, 2007 9:50 pm    Post subject: Reply with quote

Ho notato una cosa, e non saprei ora dire se il problema è sorto ora o c'è sempre stato..... me ne accorgo solo ora.
Non appare VOLUME ON quando disattivo il muto, ma esce ancora VOLUME OFF.

Chè è?
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Thu Mar 01, 2007 10:27 pm    Post subject: Reply with quote

bandreabis wrote:
Ho notato una cosa, e non saprei ora dire se il problema è sorto ora o c'è sempre stato..... me ne accorgo solo ora.
Non appare VOLUME ON quando disattivo il muto, ma esce ancora VOLUME OFF.

Chè è?

Veramente, con lineakd e osd, mi appare "volume muted" per off e la barra volume quando torno a on. ma non mi appare ne "volume on" ne "volume off".
Non saprei dirti...
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2489
Location: イタリアのロディで

PostPosted: Thu Mar 01, 2007 10:29 pm    Post subject: Reply with quote

skypjack wrote:
bandreabis wrote:
Ho notato una cosa, e non saprei ora dire se il problema è sorto ora o c'è sempre stato..... me ne accorgo solo ora.
Non appare VOLUME ON quando disattivo il muto, ma esce ancora VOLUME OFF.

Chè è?

Veramente, con lineakd e osd, mi appare "volume muted" per off e la barra volume quando torno a on. ma non mi appare ne "volume on" ne "volume off".
Non saprei dirti...


Io sto usando volume-osd di mouser.

Scusa.
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
noice
Guru
Guru


Joined: 05 Dec 2005
Posts: 473
Location: italia, Ischia

PostPosted: Sat Mar 31, 2007 12:41 am    Post subject: Reply with quote

bandreabis wrote:
Ho notato una cosa, e non saprei ora dire se il problema è sorto ora o c'è sempre stato..... me ne accorgo solo ora.
Non appare VOLUME ON quando disattivo il muto, ma esce ancora VOLUME OFF.

Chè è?


in effetti è vero ma basta cambiare
Code:
STATE="`amixer get Master | tail -1 | cut -d'[' -f3 | cut -d']' -f1`"

in
Code:
STATE="`amixer get Master | tail -1 | cut -d'[' -f4 | cut -d']' -f1`"
nel file /usr/bin/volume-osd e tutto torna alla normalita' :wink:
_________________
Noice

when you post remove comments
Code:
grep -vh '^[[:space:]]*\(#\|$\)' "$@"
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2489
Location: イタリアのロディで

PostPosted: Sun Apr 01, 2007 5:39 pm    Post subject: Reply with quote

Prefetto! :wink:
Grazie 1000.
_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
flocchini
Veteran
Veteran


Joined: 17 May 2003
Posts: 1124
Location: Milano, Italy

PostPosted: Tue Apr 10, 2007 1:29 am    Post subject: Reply with quote

skypjack wrote:
Giusta correzione.
Lo stesso accade per il mio tasto Media Direct, ko.
Se scopri come resuscitarlo, fammi sapere...


uppettino, nessuno sa quindi come resuscitare un tasto che con xev non viene visto? No, non ditemi che e' rotto perche' da quell'altro SO funge... :lol:
_________________
~~ Per amore della rosa si sopportano le spine... ~~
Back to top
View user's profile Send private message
Alberto Santini
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jul 2005
Posts: 88
Location: Italy->Sicily->Caltanissetta

PostPosted: Thu Apr 12, 2007 10:12 am    Post subject: Reply with quote

Io ho usato xbindkeys per comandare amaroK, dalla mia tastiera HP RT7H10... ho fatto uno script per ogni tasto, ma ovviamente se ne puo' usare uno solo che prenda l'azione da compiere come parametro.. solo, non avevo voglia :)

~/.xbindkeysrc
Code:

"/home/alberto/Programmi/bin/amarok-playpause"
        m:0x0 + c:162

"/home/alberto/Programmi/bin/amarok-prev"
        m:0x0 + c:144

"/home/alberto/Programmi/bin/amarok-next"
        m:0x0 + c:153

"/home/alberto/Programmi/bin/amarok-stop"
        m:0x0 + c:164


amarok-playpause
Code:

#!/bin/bash

amarokRunning=`ps cx | grep amarokapp`

if [ -n "$amarokRunning" ]
then
        amarokStatus=`dcop amarok player status`
        if [ "$amarokStatus" = "0" ]
        then
                dcop amarok player play
        else
                dcop amarok player pause
        fi
else
        amarok
fi


amarok-prev
Code:

#!/bin/bash

amarokRunning=`ps cx | grep amarokapp`

if [ -n "$amarokRunning" ]
then
        amarokStatus=`dcop amarok player status`
        if [ "$amarokStatus" = "0" ]
        then
                dcop amarok player play
        else
                dcop amarok player prev
        fi
else
        amarok
fi


amarok-next
Code:

#!/bin/bash

amarokRunning=`ps cx | grep amarokapp`

if [ -n "$amarokRunning" ]
then
        amarokStatus=`dcop amarok player status`
        if [ "$amarokStatus" = "0" ]
        then
                dcop amarok player play
        else
                dcop amarok player next
        fi
else
        amarok
fi


amarok-stop
Code:

#!/bin/bash

amarokRunning=`ps cx | grep amarokapp`

if [ -n "$amarokRunning" ]
then
        amarokStatus=`dcop amarok player status`
        if [ "$amarokStatus" != "0" ]
                dcop amarok player stop
        fi
fi
Back to top
View user's profile Send private message
gieffe
n00b
n00b


Joined: 26 Sep 2007
Posts: 19

PostPosted: Thu Apr 17, 2008 10:26 pm    Post subject: Reply with quote

purtroppo il link per il download dello script volume-osd sul sito di mouser non funziona più...
qualcun altro può passarmelo please? (anche per pm...)
Back to top
View user's profile Send private message
bandreabis
Advocate
Advocate


Joined: 18 Feb 2005
Posts: 2489
Location: イタリアのロディで

PostPosted: Tue Jun 02, 2009 11:10 am    Post subject: Reply with quote

E' passato taaanto tempo, ma se serve ancora:
Code:

#!/bin/bash
#
# Increase/Decrease/Mute/Unmute volume and write on screen
#
# (c)oded by Matteo <mouser> Cappadonna

FONT="-adobe-helvetica-bold-*-*-*-16-*-*-*-*-*-*-*"
COLOR="blue"
ALIGN="right"
POS="bottom"
OFFSET="60"
DELAY="2"
BARMODE="percentage"


case $1 in
        '+')    amixer set Master 5%+ &> /dev/null
                PERCENT="`amixer get Master | tail -1 | cut -d'[' -f2 | cut -d']' -f1 | sed s/'%'//`"
                pkill osd_cat
                osd_cat --font=$FONT --color=$COLOR --align=$ALIGN --pos=$POS --offset=$OFFSET --delay=$DELAY --barmode=$BARMODE --percentage=$PERCENT -T "Volume: $PERCENT%"
                ;;

        '-')    amixer set Master 5%- &> /dev/null
                PERCENT="`amixer get Master | tail -1 | cut -d'[' -f2 | cut -d']' -f1 | sed s/'%'//`"
                pkill osd_cat
                osd_cat --font=$FONT --color=$COLOR --align=$ALIGN --pos=$POS --offset=$OFFSET --delay=$DELAY --barmode=$BARMODE --percentage=$PERCENT -T "Volume: $PERCENT%"
                ;;

        *)      amixer set Master toggle &> /dev/null
                TMPFILE="tempfile"
                STATE="`amixer get Master | tail -1 | cut -d'[' -f4 | cut -d']' -f1`"
                if [ "$STATE" = "on" ]; then
                        echo "Volume ON" > $TMPFILE
                else
                        echo "Volume OFF" > $TMPFILE
                fi
                pkill osd_cat
                osd_cat --font=$FONT --color=$COLOR --align=$ALIGN --pos=$POS --offset=$OFFSET --delay=$DELAY $TMPFILE
                rm $TMPFILE
                ;;

esac




# dobe-helvetica-bold

_________________
Il numero di post non fa di me un esperto! Anzi!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum