Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index International Gentoo Users Forum italiano (Italian) Forum di discussione italiano
  • Search

[RISOLTO]ACPID è razzista:esegue solo i comandi che gli pare

Tutte le discussioni direttamente correlabili all'informatica e/o a GNU/*nix.

Moderator: ago

Post Reply
  • Print view
Advanced search
35 posts
  • 1
  • 2
  • Next
Author
Message
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

[RISOLTO]ACPID è razzista:esegue solo i comandi che gli pare

  • Quote

Post by fbcyborg » Sun Feb 26, 2012 5:48 pm

Scusate il titolo un po' a modalità sfogo, ma è la realtà.

In rete ho trovato uno script che fa la seguente cosa: attiva il touchpad se è disattivato e viceversa.
È semplicissimo e funziona alla grande:

Code: Select all

if [ $(synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then synclient TouchpadOff=1; elif [ $(synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then synclient TouchpadOff=2; else synclient TouchpadOff=2; fi
Funziona da root e da utente. Una favola.

Ebbene, sul mio laptop ho un tasto (F1) che su winsozz premuto in combinazione con Fn abilita e disabilita il touchpad. Vorrei fare la stessa cosa su Linux, quindi avendo trovato quello script, che funziona, vorrei bindarlo all'evento ACPI che viene catturato tramite la pressione di quella combinazione di tasti: Fn+F1.

Ecco cosa ho fatto:

Code: Select all

tail -0f /var/log/messages
Ho scoperto che l'evento da catturare è questo:

Code: Select all

button/fnf1 FNF1 00000080 00000000
Quindi ho creato un file con il seguente contenuto:

Code: Select all

event=button/fnf1 FNF1 00000080 00000000
action=/etc/acpi/actions/toggle_touchpad.sh
Il file toggle_touchpad.sh contiene appunto lo script sopra riportato.

Ebbene, riavvio acpid, e provo: niente. Il touchpad non viene disattivato.

Se invece provo a scrivere "wall hello world" (senza le virgolette) dopo "action=", funziona.
Mi viene notificata la scritta "hello world". Quindi l'evento viene catturato.

Ma allora perché lo scriptino che ho messo io non funziona?
Da solo funziona, in acpid no. Perché?
Last edited by fbcyborg on Tue Feb 28, 2012 9:28 am, edited 1 time in total.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
MajinJoko
l33t
l33t
User avatar
Posts: 639
Joined: Tue Sep 20, 2005 6:00 pm
Location: Bergamo / Verona

  • Quote

Post by MajinJoko » Sun Feb 26, 2012 6:57 pm

perdona la stupidità.

è eseguibile? (permessi di esecuzione, partizione in noexec)

tutto qui :(
[(.. watashi wa Urumi Kanzaki ga suki da ..)]
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Sun Feb 26, 2012 7:11 pm

Certamente. Lo script lanciato da riga di comando va che una meraviglia. Permessi strani non ce ne sono.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
xdarma
l33t
l33t
User avatar
Posts: 720
Joined: Mon Dec 08, 2003 11:05 am
Location: tra veneto e friuli (italy)

Re: ACPID è razzista: esegue solo i comandi che gli pare

  • Quote

Post by xdarma » Sun Feb 26, 2012 8:21 pm

Code: Select all

event=button/fnf1 FNF1 00000080 00000000
action=/etc/acpi/actions/toggle_touchpad.sh
Prova ad aggiungere "%e" in coda ad "action=..."
proud user of faKeDE-4.7.3 -> back to windowmaker -> moved to LXQt
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Sun Feb 26, 2012 8:23 pm

Grazie, ci avevo già provato, non va!
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
Zizo
Apprentice
Apprentice
User avatar
Posts: 200
Joined: Thu Feb 04, 2010 9:14 am
Location: Padova, Italy

  • Quote

Post by Zizo » Mon Feb 27, 2012 7:08 am

Aggiungerei qualche echo/wall di debug che chiarisca se lo script viene eseguito ma non fa nulla o non viene eseguito proprio (cosa che dovresti già capire da messages). Per sicurezza proverei ad utilizzare i percorsi completi.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 8:11 am

Zizo wrote:Aggiungerei qualche echo/wall di debug che chiarisca se lo script viene eseguito ma non fa nulla o non viene eseguito proprio (cosa che dovresti già capire da messages). Per sicurezza proverei ad utilizzare i percorsi completi.
Allora, i percorsi, anzi il percorso che uso è completo, infatti:

Code: Select all

action=/etc/acpi/actions/toggle_touchpad.sh
Come ho scritto nel primo post, se provo con un "wall" funziona, infatti il popup del messaggio compare.
In pratica quello script (qualsiasi script "più complesso" e non un semplice comando) viene ignorato.
Infatti, anche se inserisco la seguente linea in "action=" senza richiamare script esterni non funziona lo stesso:

Code: Select all

if [ $(synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then synclient TouchpadOff=1; elif [ $(synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then synclient TouchpadOff=2; else synclient TouchpadOff=2; fi
Se metto "action=wall hello" funziona.
È come se non volesse eseguire istruzioni complesse. Fra l'altro questa è una cosa che un tempo facevo senza problemi, seguendo una vecchia guida riportata qui.

Al momento della pressione di Fn+F1 il log riporta quanto segue:

Code: Select all

acpid: received input layer event "button/fnf1 FNF1 00000080 00000000"
acpid: rule from /etc/acpi/events/fn_f1 matched
acpid: executing action "/etc/acpi/actions/toggle_touchpad.sh"
acpid: action exited with status 1
acpid: rule from /etc/acpi/events/default matched
acpid: executing action "/etc/acpi/default.sh button/fnf1 FNF1 00000080 00000000"
nobody: ACPI event unhandled: button/fnf1 FNF1 00000080 00000000
acpid: action exited with status 0
acpid: 2 total rules matched
acpid: completed input layer event "button/fnf1 FNF1 00000080 00000000"
acpid: received netlink event "sony/hotkey SNY5001:00 00000001 0000000c"
acpid: rule from /etc/acpi/events/default matched
acpid: executing action "/etc/acpi/default.sh sony/hotkey SNY5001:00 00000001 0000000c"
nobody: ACPI event unhandled: sony/hotkey SNY5001:00 00000001 0000000c
acpid: action exited with status 0
acpid: 1 total rule matched
acpid: completed netlink event "sony/hotkey SNY5001:00 00000001 0000000c"
acpid: received netlink event "sony/hotkey SNY5001:00 00000001 0000003b"
acpid: rule from /etc/acpi/events/default matched
acpid: executing action "/etc/acpi/default.sh sony/hotkey SNY5001:00 00000001 0000003b"
nobody: ACPI event unhandled: sony/hotkey SNY5001:00 00000001 0000003b
acpid: action exited with status 0
acpid: 1 total rule matched
acpid: completed netlink event "sony/hotkey SNY5001:00 00000001 0000003b"
Sinceramente non capisco. Prima esce con stato 1 e poi con stato 0. Inoltre è come se la pressione del tasto fosse multipla, mentre invece io premo una volta sola.
In ogni caso rispondo subito alla domanda "ma se è così allora il touchpad viene disattivato e riattivato subito?": no perché ho provato anche uno script diverso che lo disattiva e basta tramite xinput, e il problema rimane.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
Zizo
Apprentice
Apprentice
User avatar
Posts: 200
Joined: Thu Feb 04, 2010 9:14 am
Location: Padova, Italy

  • Quote

Post by Zizo » Mon Feb 27, 2012 10:13 am

Stando al log riportato la pressione del tasto genera tre eventi:

Code: Select all

 - Pressione: button/fnf1 FNF1 00000080 00000000
              sony/hotkey SNY5001:00 00000001 0000000c

 - Rilascio:  sony/hotkey SNY5001:00 00000001 0000003b
Hai deciso di utilizzare l'evento "button/fnf1 FNF1 00000080 00000000" e alla sua occorrenza eseguire lo script "/etc/acpi/actions/toggle_touchpad.sh".
Acpid ubbidisce all'ordine ma lo script fallisce ed esce con un errore:

Code: Select all

acpid: received input layer event "button/fnf1 FNF1 00000080 00000000"
acpid: rule from /etc/acpi/events/fn_f1 matched
acpid: executing action "/etc/acpi/actions/toggle_touchpad.sh"
acpid: action exited with status 1 
Questo permette di circoscrivere il problema allo script.
Per "utilizzare i percorsi completi" intendo infatti all'interno di quest'ultimo, usando per esempio (ipotizzo) "/usr/bin/synclient" anzichè solo "synclient", questo nel caso acpid non utilizzi un ambiente completo e uno dei comandi dello script non sia presente nel PATH usato.
Inoltre quando riporti lo script noto l'assenza della riga di shebang "#!/bin/sh".
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 11:44 am

A parte il fatto che non capisco perché lo script non funzioni quando è la prima volta che lo lancio da riga di comando, comunque il motivo per cui non funziona è sicuramente un altro.
Anche posizionandolo in /usr/bin/toggle_touchpad.sh non cambia nulla.
Zizo wrote:Stando al log riportato la pressione del tasto genera tre eventi:

Code: Select all

 - Pressione: button/fnf1 FNF1 00000080 00000000
              sony/hotkey SNY5001:00 00000001 0000000c

 - Rilascio:  sony/hotkey SNY5001:00 00000001 0000003b
Hai deciso di utilizzare l'evento "button/fnf1 FNF1 00000080 00000000" e alla sua occorrenza eseguire lo script "/etc/acpi/actions/toggle_touchpad.sh".
Acpid ubbidisce all'ordine ma lo script fallisce ed esce con un errore:

Code: Select all

acpid: received input layer event "button/fnf1 FNF1 00000080 00000000"
acpid: rule from /etc/acpi/events/fn_f1 matched
acpid: executing action "/etc/acpi/actions/toggle_touchpad.sh"
acpid: action exited with status 1 
Questo permette di circoscrivere il problema allo script.
OK, e questo ci sta, ma il valore di ritorno 1 ci dice poco.
Zizo wrote: Per "utilizzare i percorsi completi" intendo infatti all'interno di quest'ultimo, usando per esempio (ipotizzo) "/usr/bin/synclient" anzichè solo "synclient", questo nel caso acpid non utilizzi un ambiente completo e uno dei comandi dello script non sia presente nel PATH usato.
Hai ragione, non avevo capito.
Comunque ci ho provato ma non funziona lo stesso.
Zizo wrote: Inoltre quando riporti lo script noto l'assenza della riga di shebang "#!/bin/sh".
Quello è colpa mia. Ho riportato lo script ma senza il #!/bin/sh, in realtà c'è.

Ecco lo script completo (funzionante se lanciato da riga di comando), con i percorsi completi:

Code: Select all

#!/bin/bash

if [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then /usr/bin/synclient TouchpadOff=1; elif [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then /usr/bin/synclient TouchpadOff=2; else /usr/bin/synclient TouchpadOff=2; fi

EDIT:
Comunque ecco cosa rileva acpi_listen alla pressione di Fn+F1:

Code: Select all

button/fnf1 FNF1 00000080 00000000
sony/hotkey SNY5001:00 00000001 0000000c
sony/hotkey SNY5001:00 00000001 0000003b
Forse catturo l'evento sbagliato?

EDIT: No... anche impostando "sony/hotkey SNY5001:00 00000001 0000003b" come event, non cambia nulla.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
djinnZ
Advocate
Advocate
User avatar
Posts: 4831
Joined: Thu Nov 02, 2006 12:47 pm
Location: somewhere in L.O.S.
Contact:
Contact djinnZ
Website

  • Quote

Post by djinnZ » Mon Feb 27, 2012 1:22 pm

fbcyborg wrote:#!/bin/sh
if [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then /usr/bin/synclient TouchpadOff=1; elif [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then /usr/bin/synclient TouchpadOff=2; else /usr/bin/synclient TouchpadOff=2; fi
Poi ti lamenti che ti tratto male... (perché escogiti sempre modi per far venire il mal di testa al prossimo, una sintassi del genere la si usa per le azioni in linea singola)
Sprecarti ad usare la corretta indentazione è male?
Correggi lo script (così è una ciofeca da windozziani o da utonti ubuntu, quanto meno dovrebbe gestire gli stati di uscita di synclient e generarne di propri) e prova se

Code: Select all

source /etc/profile
o

Code: Select all

action=/bin/sh -c /etc/[i]vattelappesca[/i]
sono d'aiuto.

In questi ambiti si deve essere sempre minimalisti, inverosimilmente minimalisti... :wink: e rigorosamente posix ... :wink: e si usano le funzioni builtin della shell ... :? ma capisco che è un modo troppo antiquato di pensare ... :twisted:
scita et risus abundant in ore stultorum sed etiam semper severi insani sunt:wink:
mala tempora currunt...mater stultorum semper pregna est :evil:
Murpy'sLaw:If anything can go wrong, it will - O'Toole's Corollary:Murphy was an optimist :wink:
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 1:39 pm

Grazie djinnZ.

Dunque, gli errori che ho commesso, sono semplicemente frutto del fatto che di bash non ne capisco assolutamente niente. Sebbene abbia esperienza con altri linguaggi di programmazione, bash è ancora una barriera che spero di oltrepassare presto.

Non mi vergogno di ripetere che quello script l'ho trovato su Internet e che è quasi del tutto arabo per me... più che altro la sintassi.
Ovviamente capisco la logica ecc.. ma non sarei mai stato in grado di scriverlo in bash.

Sull'indentazione sono d'accordo. Hai perfettamente ragione. Sono solito usarla fra l'altro.

Di sicuro lo script va migliorato. Magari provo a fare qualcosa, per quel poco che ne capisco.

Di sicuro così è più leggibile:

Code: Select all

#!/bin/bash

if [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then 
    /usr/bin/synclient TouchpadOff=1; 
elif [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then 
    /usr/bin/synclient TouchpadOff=2; 
else 
    /usr/bin/synclient TouchpadOff=2;
fi

Code: Select all

event=button/fnf1 FNF1 00000080 00000000
action=/bin/sh -c /etc/acpi/actions/toggle_touchpad.sh
Di fatto però non cambia nulla:

Code: Select all

acpid: received input layer event "button/fnf1 FNF1 00000080 00000000"
acpid: rule from /etc/acpi/events/fn_f1 matched
acpid: executing action "/bin/sh -c /etc/acpi/actions/toggle_touchpad.sh"
acpid: action exited with status 1
acpid: rule from /etc/acpi/events/default matched
acpid: executing action "/etc/acpi/default.sh button/fnf1 FNF1 00000080 00000000"
nobody: ACPI event unhandled: button/fnf1 FNF1 00000080 00000000
acpid: action exited with status 0
acpid: 2 total rules matched
acpid: completed input layer event "button/fnf1 FNF1 00000080 00000000"
acpid: received netlink event "sony/hotkey SNY5001:00 00000001 0000000c"
acpid: rule from /etc/acpi/events/default matched
acpid: executing action "/etc/acpi/default.sh sony/hotkey SNY5001:00 00000001 0000000c"
nobody: ACPI event unhandled: sony/hotkey SNY5001:00 00000001 0000000c
acpid: action exited with status 0
acpid: 1 total rule matched
acpid: completed netlink event "sony/hotkey SNY5001:00 00000001 0000000c"
acpid: received netlink event "sony/hotkey SNY5001:00 00000001 0000003b"
acpid: rule from /etc/acpi/events/default matched
acpid: executing action "/etc/acpi/default.sh sony/hotkey SNY5001:00 00000001 0000003b"
nobody: ACPI event unhandled: sony/hotkey SNY5001:00 00000001 0000003b
acpid: action exited with status 0
acpid: 1 total rule matched
acpid: completed netlink event "sony/hotkey SNY5001:00 00000001 0000003b"
Ho fatto anche il source /etc/profile come consigliato ovviamente.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Mon Feb 27, 2012 5:45 pm

Non funziona perchè synclient lanciato da quell'ambiente non riesce a connettersi al server X ed esce con errore.
Per rendertene conto ti basta aggiungere la riga:

Code: Select all

synclient -l 2> /tmp/log
in testa allo script.
Andando ad esaminare il log vedrai:

Code: Select all

Failed to connect to X Server.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 6:20 pm

No, a me risulta vuoto quel file!

Sempre se ho capito bene, ho impostato il file in questo modo:

Code: Select all

#!/bin/sh

synclient -l 2> /tmp/log
Il file viene creato, ma dentro non stampa nulla alla pressione di Fn+F1.

Dove sbaglio?
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Mon Feb 27, 2012 7:33 pm

Strano. A me dava quell'errore per cui ho pensato che fosse uguale per il tuo sistema. Il fatto che il file venga creato ma è vuoto indica che lo script viene eseguito ma che synclient non da errori (2> redirige lo stderr).
A questo punto vedi cosa succede con:

Code: Select all

#!/bin/sh
/usr/bin/synclient -l > /tmp/log1 2> /tmp/log2
In log1 troverai lo standard output del comando mentre in log2 gli errori; affinché il tuo script possa funzionare in log1 ci dovrebbero essere tutti i vari valori restituiti da synclient, ma probabilmente sarà vuoto.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 8:04 pm

armaoin wrote:Strano. A me dava quell'errore per cui ho pensato che fosse uguale per il tuo sistema.
Non lo so... può anche darsi che io stia sbagliando qualcosa, ma mi pare di aver fatto bene.
armaoin wrote: Il fatto che il file venga creato ma è vuoto indica che lo script viene eseguito ma che synclient non da errori (2> redirige lo stderr).
In realtà quel comando, da l'errore "Failed to connect to X Server." solo se lo lancio via SSH da remoto, e ci sta che succeda quella cosa.
Invece, quando lo lancio dal PC in questione, l'output è questo (notare riga 1).
armaoin wrote: A questo punto vedi cosa succede con:

Code: Select all

#!/bin/sh
/usr/bin/synclient -l > /tmp/log1 2> /tmp/log2
In log1 troverai lo standard output del comando mentre in log2 gli errori; affinché il tuo script possa funzionare in log1 ci dovrebbero essere tutti i vari valori restituiti da synclient, ma probabilmente sarà vuoto.
log1 è vuoto, mentre log2 sputa fuori il famoso "Failed to connect to X Server". :? :?

Non ci sto capendo più nulla.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Mon Feb 27, 2012 8:13 pm

Abbiamo quindi appurato che il problema è che synclient lanciato in quell'ambiente non funziona in quanto non riesce a trovare X. Probabilmente bisogna impostare qualche variabile d'ambiente per far si che synclient possa connettersi al server (mi viene in mente DISPLAY ad esempio), ma purtroppo dovrai aspettare qualcuno che ne capisce più di me per risolvere il problema.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 8:17 pm

OK.

Prima di iniziare questo thread, stavo pensando ad una cosa: si potrebbe usare sudo per lanciare lo script dall'utente correntemente loggato invece che da root?
Poi magari non funziona...
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Mon Feb 27, 2012 8:36 pm

fbcyborg wrote:OK.

Prima di iniziare questo thread, stavo pensando ad una cosa: si potrebbe usare sudo per lanciare lo script dall'utente correntemente loggato invece che da root?
Poi magari non funziona...
Scusa ma non ho capito perchè dovresti lanciarlo da root. Se vuoi lanciare lo script manualmente lo puoi usare benissimo da utente normale (non c'è bisogno di essere root per impostare il touchpad con synclient).
Personalmente non passarei da acpi e proverei a creare una scorciatoia di tastiera che esegue lo script ogni volta che che premi Fn+F1 (o se magari questa combinazione non viene riconosciuta dall'ambiente desktop binderei lo script a un'altra combinazione di tasti CTRL+ALT+F1 o quello che ti pare); il metodo per farlo ovviamente cambia a seconda dell'ambiente desktop che usi.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Mon Feb 27, 2012 8:45 pm

Allora, il punto cruciale è che io vorrei abilitare/disabilitare il touchpad premendo Fn+F1.
Questo posso farlo se catturo l'evento acpi collegato alla pressione di quella combinazione ti tasti.
Fin qui, penso sia chiaro.

Questo acpi, se non sbaglio funziona da root.
Da qui le varie prove nel lanciare lo script da utente o da root.

Per la scorciatoia da tastiera, ci ho pensato, ma in KDE systemsettings non c'è la possibilità (almeno che io sappia) di catturare l'evento di pressione Fn+F1, alrimenti avrei già risolto.
Io vorrei impostare Fn+F1, e non trovare alternative tipo CTRL+ALT+F1.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Tue Feb 28, 2012 12:06 am

Mi sono documentato un po e ho tirato fuori questo script per acpid che funziona:

Code: Select all

event=IL CODICE DI Fn+F1
action=/etc/acpi/actions/touch.sh

Code: Select all

#!/bin/sh 
AUTH=/var/run/slim.auth
DISPLAY=:0

cp $AUTH /root/.Xauthority
export DISPLAY

if [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') = "2" ]; then 
    /usr/bin/synclient TouchpadOff=1; 
elif [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') = "1" ]; then 
    /usr/bin/synclient TouchpadOff=2; 
else 
    /usr/bin/synclient TouchpadOff=2; 
fi

rm /root/.Xauthority
unset DISPLAY
Ovviamente devi modificare DISPLAY e AUTH per il tuo sistema: se usi un solo server X allora DISPLAY va bene in quel modo; per il file di XAUTH cambia a seconda di come avvii il server grafico (come avrai capito io uso slim); per capire quale è il file fai:

Code: Select all

$ ps aux | grep /usr/bin/X
root     16108  3.5  0.8 124488 35320 tty7     Ss+  00:24   1:08 /usr/bin/X -nolisten tcp -br -deferglyphs 16 -auth /var/run/slim.auth vt07
Nel caso di kdm dovrebbe essere /var/run/xauth (ma non lo posso verificare non avendo kdm).

Cosi il tutto funziona ma non so se ci potrebbero essere problemi di qualche tipo (trovo un pò brutale il modo in cui forzo l'accesso a X ma non so se ci sono altri metodi) e sicuramente lo script può essere migliorato dato che io di bash ne so veramente poco. Cosi a prima vista direi che ci potrebbero essere problemi in caso accedi all'ambiente grafico come root (ma in genere non si dovrebbe fare) dato che alla fine lo script cancella .Xauthority.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Tue Feb 28, 2012 9:27 am

Ehi grazie, ho provato e funziona perfettamente!

Ecco l'AUTH nel caso di KDM:

Code: Select all

AUTH=/var/run/xauth/A:0-xBgkWa

Ora resta da capire perché la prima volta che tale script viene lanciato non funziona, ma questo è un altro discorso.
Metto il tag risolto. Di fatto, se trovassi in giro uno script migliore non dovrei avere grossi problemi per farlo funzionare, questa volta, una volta scoperto il motivo.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Tue Feb 28, 2012 9:56 am

fbcyborg wrote: Ora resta da capire perché la prima volta che tale script viene lanciato non funziona, ma questo è un altro discorso.
Metto il tag risolto. Di fatto, se trovassi in giro uno script migliore non dovrei avere grossi problemi per farlo funzionare, questa volta, una volta scoperto il motivo.
Te la butto li:
La prima volta il valore di TouchpadOff è 0 per cui lo script lo imposta a 2.
La seconda volta il valore è 2 per cui correttamente lo imposta a 1.

Soluzione:
Impostare TouchpadOff a 2 appena avvii il DE.

Soluzione2:
Modfica il codice if per far si che il codice venga eseguito sia per Touchpadoff == 2 che per Touchpadoff == 0

EDIT:
oppure meglio ancora:

Code: Select all

#!/bin/sh 
AUTH=/var/run/slim.auth 
DISPLAY=:0 

cp $AUTH /root/.Xauthority 
export DISPLAY 

if [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') != "1" ]; then 
    /usr/bin/synclient TouchpadOff=1; 
else 
    /usr/bin/synclient TouchpadOff=0; 
fi 

rm /root/.Xauthority 
unset DISPLAY 
Vedi se cosi funziona.
Last edited by armaoin on Tue Feb 28, 2012 10:07 am, edited 3 times in total.
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Tue Feb 28, 2012 10:00 am

Allora, ho appena modificato lo script, e mi hai risposto contemporaneamente...

L'ho modificato così (banalmente direi):

Code: Select all

#!/bin/bash

AUTH=/var/run/xauth/A:0-xBgkWa
DISPLAY=:0

cp $AUTH /root/.Xauthority 
export DISPLAY

if [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') = "0" ]; then 
        /usr/bin/synclient TouchpadOff=1; 
elif [ $(/usr/bin/synclient -l | grep TouchpadOff | awk '{print $3}') == "1" ]; then 
        /usr/bin/synclient TouchpadOff=0; 
fi

rm /root/.Xauthority 
unset DISPLAY
Fra l'altro, non da più neanche un altro problema (click on tap non funzionava al ripristino).

Fin'ora problemi non ne da... e non capisco a cosa serva settarlo al valore 2.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
armaoin
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 110
Joined: Sun Apr 02, 2006 10:42 am

  • Quote

Post by armaoin » Tue Feb 28, 2012 10:03 am

Guarda il mio edit.
TouchpadOff=0 touchpad + tap attivato
TouchpadOff=1 touchpad disattivato
TouchpadOff=2 disabilita solo il tapping

Se vuoi quindi il tap abilitato metti Touchpad = 0 al posto di 2 (ho modificato lo script precedente per averlo con il tap attivo).
Top
fbcyborg
Advocate
Advocate
User avatar
Posts: 3056
Joined: Sun Oct 16, 2005 12:08 pm
Location: ROMA

  • Quote

Post by fbcyborg » Tue Feb 28, 2012 10:08 am

Grazie, ho letto, ma in realtà a me va bene che "switchi" fra 0 e 1.
Infatti per come ho modificato lo script io, sembra che vada perfettamente.
Se è attivo lo disattivo, altrimenti lo attivo. Semplicissimo direi.

In ogni caso, grazie per il chiarimento ulteriore sul valore 2.
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Top
Post Reply
  • Print view

35 posts
  • 1
  • 2
  • Next

Return to “Forum di discussione italiano”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic