You are not logged in.

#1 2016-01-11 14:42:13

esa
Member
Registered: 2011-12-29
Posts: 143
Website

[SOLVED][lua] AwesomeWM - Mouse & keyboard interactions

Heyas everyone

I recently started modifying my rc.lua (more than just adding existing vicious widgets) and finaly wanted to apply some hotkeys, for the volume.
Related snippets provided, full config: https://github.com/sri-arjuna/awesome

I was able to add: (./rc/complex/vol)

  • Left mouse click (toggle mute)

--
-- Mouse interactions
--
	-- Left button for volume up
	volume_icon:buttons(awful.util.table.join(
		awful.button({ }, 5, function () 
			--os.execute( term_cmd .. "\"" .. DIR_SCRIPTS .. "/snd.sh up" .. "\""  ) 
			--os.execute( "amixer -c 0 set Master 5db+")
			--msgbox("Volume up")
			--update_icon()
			volume_change("up")
		end)
	))
	-- Right button for volume down
	volume_icon:buttons(awful.util.table.join(
		awful.button({ }, 4, function () 
			--os.execute( term_cmd .. "\"" .. DIR_SCRIPTS .. "/snd.sh down" .. "\""  ) 
			--msgbox("Volume down") 
			--update_icon()
			volume_change("down")
		end)
	))
	-- Wheel click for volume mute toggle
	volume_icon:buttons(awful.util.table.join(
		awful.button({ }, 1, function () 
			--os.execute( term_cmd .. "\"" .. DIR_SCRIPTS .. "/snd.sh mute" .. "\""  ) 
			--msgbox("Volume toggle (mute)") 
			--update_icon()
			volume_change("mute")
		end)
	))

Sadly, volume up/down/mute only works when using VLC, regardless of which hotkey assignemt i choose (./rc/config-hotkeys)

	-- Volume (FN + F9/F10/F11)
	awful.key({modkey}, "#122", 	volume_change("down"), update_icon()),
	awful.key({modkey}, "#123", 	volume_change("up"), update_icon),
	--awful.key({modkey}, "#124", 	volume_change("mute"), update_icon),
	--awful.key({modkey, "Fn"}, "F9", 	volume_change("down"), update_icon()),
	--awful.key({modkey, "Fn"}, "F10", 	volume_change("up"), update_icon),
	--awful.key({modkey, "Fn"}, "F11", 	volume_change("mute"), update_icon),
	-- Volume controls | Multimedia keys: Volume Up/Down Mute
	--  awful.key({ }, "XF86AudioRaiseVolume", 	volume_change("up"), update_icon()),
	--  awful.key({ }, "XF86AudioLowerVolume", 	volume_change("down"), update_icon()),
	--  awful.key({ }, "XF86AudioMute", 		volume_change("mute"), update_icon()),
	

2 Things i do not understand.

  1. Why are these 'hotkeys' executed upon (re-)loading awesome? (i do see 'volume up'/'volume down'/'volume mute' when loading  when all the 3 hotkeys are 'available' (not commented out) in the rc.lua.

  2. Why do the hotkeys only work with VLC, evenghouh the msgbox (a 'control' function around naughty) display its usage upon (re-)loading awesome, but not when pressing the hotkeys.. not even when vlc is running and the volume is changed....

Functions used:

--
-- Functions
--
	function update_icon() 
		local icon = get_bash_string( DIR_SCRIPTS .. "/snd.sh","image")
		volume_icon:set_image( DIR_ICONS .. "/snd/" .. icon )
	end
	function volume_change(mode)
		os.execute( term_cmd .. "\"" .. DIR_SCRIPTS .. "/snd.sh " .. mode .. "\""  ) 
		msgbox("Volume " .. mode ) 
		update_icon()
	end
	function msgbox(msg)
		naughty.notify({ 
			preset = naughty.config.presets.info, 
			title = msg,
			text = err
		})
	end

Again, what i fail to figure out is why 'fn + f9' does not change the volume on 'plain desktop', and even IF it does (while vlc is running) - why is msgbox not shown?!

And advice or ideas please?
Thank you in advance.

EDIT:
FYI: There is NO errormessage at all, if there was, i would have an idea where to look/get started.

Last edited by esa (2016-01-12 05:38:36)


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

#2 2016-01-11 16:02:03

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: [SOLVED][lua] AwesomeWM - Mouse & keyboard interactions

Try running xev to see what it actually registers as.


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#3 2016-01-11 17:26:26

esa
Member
Registered: 2011-12-29
Posts: 143
Website

Re: [SOLVED][lua] AwesomeWM - Mouse & keyboard interactions

Thank you for your response.

I got the current key values #122 #123 from xev.

KeyPress event, serial 33, synthetic NO, window 0x600001,
    root 0xc8, subw 0x0, time 232233875, (419,528), root:(419,549),
    state 0x10, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x600001,
    root 0xc8, subw 0x0, time 232233956, (419,528), root:(419,549),
    state 0x10, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 33, synthetic NO, window 0x600001,
    root 0xc8, subw 0x0, time 232235147, (419,528), root:(419,549),
    state 0x10, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x600001,
    root 0xc8, subw 0x0, time 232235207, (419,528), root:(419,549),
    state 0x10, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 33, synthetic NO, window 0x600001,
    root 0xc8, subw 0x0, time 232236685, (419,528), root:(419,549),
    state 0x10, keycode 121 (keysym 0x1008ff12, XF86AudioMute), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x600001,
    root 0xc8, subw 0x0, time 232236693, (419,528), root:(419,549),
    state 0x10, keycode 121 (keysym 0x1008ff12, XF86AudioMute), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

This is with 'Fn' pressed, though, pressing 'Fn' doesnt give ANY output at all.
When 'Fn' is not pressed, the keycode values are lower by ~50.

Also, to my understanding, if i would had chosen/taken the wrong numbers (keycode), it would not work in VLC, nor anywhere else.

Or raise an error message, at least?

EDIT:
Well, i didnt take 'mute' from there, but that is the least of my issues (since i still can click on the icon to mute it, and get the msgbox ;; but not when mousewheel is scrolled)

Last edited by esa (2016-01-11 17:28:07)


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

#4 2016-01-11 22:33:23

esa
Member
Registered: 2011-12-29
Posts: 143
Website

Re: [SOLVED][lua] AwesomeWM - Mouse & keyboard interactions

For illustration:
Clicking with the left mouse button:: --> http://imgur.com/SbH7iwG
Hitting 'Fn+F11' (laptop-mute):: --> http://imgur.com/e8amYww

The mouse clicking shows the expected behaviour, though only for the first in the code (mute).
Keystrokes dont raise msgbox (as seen in the mouse click image).

Also, that the keystrokes only work when vlc is running, is quite irritating (and kind of useless).

Any ideas that might shed some light on the issue?
Thank you in advance


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

#5 2016-01-12 05:26:55

esa
Member
Registered: 2011-12-29
Posts: 143
Website

Re: [SOLVED][lua] AwesomeWM - Mouse & keyboard interactions

OK, figured the mouse stuff.
Issue was that i had each button assignment as its own definition, which overwrote the previous assignment.
Putting them into one solved the mouse issue.

	volume_icon:buttons(awful.util.table.join(
		awful.button({ },4,function() volume_change("up") end),
		awful.button({ },5,function() volume_change("down") end),
		awful.button({ },1,function() volume_change("mute") end)
	))

Forgot to say previously: the keybindings are within:

globalkeys = awful.util.table.join(
	...
)

EDIT:
Put thebuttons into functions, et voila...

	-- Volume (FN + F9/F10/F11)
	--awful.key({}, "#122", 	function() volume_change("down") end),
	--awful.key({}, "#123", 	function() volume_change("up") end),
	--awful.key({}, "#121", 	function() volume_change("mute") end),

/solved

Last edited by esa (2016-01-12 05:38:14)


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

#6 2016-01-12 18:11:58

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: [SOLVED][lua] AwesomeWM - Mouse & keyboard interactions

I seem to be having a problem with moving windows using windows key.  The only thing that is happening is it tries to move an xterm, it tries to highlight the xterm window instead. 
Using xev, it looks like something is wrong with my mouse.
I'm using my joystick and it's still messing up.  So maybe it is whatever controls the mouse function?

Last edited by nomorewindows (2016-01-12 19:14:30)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

Board footer

Powered by FluxBB