####################
# General commands #
####################

# Enter
begin
  button = KEY_OK
  prog = irexec
  config = xte 'key Return'
end

# Escape
begin
  button = KEY_EXIT
  prog = irexec
  config = xte 'key Escape'
end

# Go up
begin
  button = KEY_UP
  prog = irexec
  config = xte 'key Up'
  repeat = 1
  delay = 3
end

# Go down
begin
  button = KEY_DOWN
  prog = irexec
  config = xte 'key Down'
  repeat = 1
  delay = 3
end

# Go left
begin
  button = KEY_LEFT
  prog = irexec
  config = xte 'key Left'
  repeat = 1
  delay = 3
end

# Go right
begin
  button = KEY_RIGHT
  prog = irexec
  config = xte 'key Right'
  repeat = 1
  delay = 3
end

# Page up
begin
  button = KEY_CHANNELUP
  prog = irexec
  config = xte 'key Page_Up'
  repeat = 1
  delay = 3
end

# Page down
begin
  button = KEY_CHANNELDOWN
  prog = irexec
  config = xte 'key Page_Down'
  repeat = 1
  delay = 3
end

# Go one level up in file browser
begin
  button = GUIDE
  prog = irexec
  config = xte 'keydown Alt_L' 'key Up' 'keyup Alt_L'
end

# Refresh
# Also start slide show in xviewer
begin
  button = AV
  prog = irexec
  config = xte 'key F5'
end

#### Enter numbers 1-9 (to choose TV channel)

begin
  button = KEY_1
  prog = irexec
  config = xte 'key 1'
end

begin
  button = KEY_2
  prog = irexec
  config = xte 'key 2'
end

begin
  button = KEY_3
  prog = irexec
  config = xte 'key 3'
end

begin
  button = KEY_4
  prog = irexec
  config = xte 'key 4'
end

begin
  button = KEY_5
  prog = irexec
  config = xte 'key 5'
end

begin
  button = KEY_6
  prog = irexec
  config = xte 'key 6'
end

begin
  button = KEY_7
  prog = irexec
  config = xte 'key 7'
end

begin
  button = KEY_8
  prog = irexec
  config = xte 'key 8'
end

begin
  button = KEY_9
  prog = irexec
  config = xte 'key 9'
end

####################
# Desktop commands #
####################

# Show main menu
begin
  button = KEY_MENU
  prog = irexec
  config = xte 'key Super_L'
end

# Show context menu
begin
  button = KEY_INFO
  prog = irexec
  config = xte 'keydown Shift_L' 'key F10' 'keyup Shift_L'
end

# Show window menu
begin
  button = PURPLE
  prog = irexec
  config = xte 'keydown Alt_L' 'key  ' 'keyup Alt_L'
end

# Show desktop (hide all windows)
begin
  button = P<P
  prog = irexec
  config = xte 'keydown Control_L' 'keydown Alt_L' 'key d' 'keyup Alt_L' 'keyup Control_L'
end

# Close window
begin
  button = KEY_POWER
  prog = irexec
  config = xte 'keydown Alt_L' 'key F4' 'keyup Alt_L'
end

# Switch between application windows
begin
  button = KEY_YELLOW
  prog = irexec
  config = xte 'keydown Alt_L' 'key Tab'
  config = xte 'keyup Alt_L'
end

##### Navigate through application windows or window panels

# Next
begin
  button = KEY_BLUE
  prog = irexec
  config = xte 'key Tab'
  repeat = 1
  delay = 3
end

# Previous
begin
  button = KEY_GREEN
  prog = irexec
  config = xte 'keydown Shift_L' 'key Tab' 'keyup Shift_L'
  repeat = 1
  delay = 3
end

##### Show application menu

begin
  button = KEY_RED
  prog = irexec
  config = xte 'key F10'
end

begin
  button = KEY_RED
  prog = irexec
  config = /home/martin/lirc-kaffeine.sh menu
end

begin
  button = KEY_RED
  prog = irexec
  config = /home/martin/lirc-vlc.sh menu
end

##### Show window in full screen mode

begin
  button = KEY_ASPECT_RATIO
  prog = vlc
  config = key-toggle-fullscreen
end

begin
  button = KEY_ASPECT_RATIO
  prog = irexec
  config = /home/martin/lirc-kaffeine.sh full
end

begin
  button = KEY_ASPECT_RATIO
  prog = irexec
  config = /home/martin/lirc-mpdevil.sh full
end

begin
  button = KEY_ASPECT_RATIO
  prog = irexec
  config = /home/martin/lirc-xviewer.sh full
end

##################
# Media commands #
##################

##### General play/pauze

begin
  button = KEY_PLAY
  prog = irexec
  config = xte 'key Space'
end

begin
  button = KEY_PAUSE
  prog = irexec
  config = xte 'key Space'
end

##### mpdevil

begin
  button = KEY_STOP
  prog = irexec
  config = /home/martin/lirc-mpdevil.sh stop
end

begin
  button = KEY_FASTFORWARD
  prog = irexec
  config = /home/martin/lirc-mpdevil.sh next
end

begin
  button = KEY_REWIND
  prog = irexec
  config = /home/martin/lirc-mpdevil.sh prev
end

begin
  button = KEY_RADIO
  prog = irexec
  config = /home/martin/lirc-mpdevil.sh random
end

##### mpd

# Load all music in to queue
begin
  button = TELETEXT_MIX
  prog = irexec
  config = mpc -h nas clear; mpc -h nas add /
end

# Empty queue
begin
  button = TELETEXT_HOLD
  prog = irexec
  config = mpc -h nas clear
end

##### VLC LIRC commands

begin
 button = KEY_STOP
 prog = vlc
 config = key-stop
end

begin
 button = KEY_FASTFORWARD
 prog = vlc
 config = key-jump+long
 repeat = 1
end

begin
 button = KEY_REWIND
 prog = vlc
 config = key-jump-long
 repeat = 1
end

# Show DVD menu
begin
  button = KEY_INFO
  prog = vlc
  config = key-disc-menu
end

##### Kaffeine

begin
  button = KEY_RECORD
  prog = irexec
  config = /home/martin/lirc-kaffeine.sh record
end

# Show TV program guide
begin
  button = KEY_INFO
  prog = irexec
  config = /home/martin/lirc-kaffeine.sh guide
end

# Show OSD (in Kaffeine configure shortcut key)
begin
  button = KEY_0
  prog = irexec
  config = xte 'key 0'
end

##### Sound

# Use PulseAudio for volume of all applications

begin
  button = KEY_VOLUMEUP
  prog = irexec
  config = pactl set-sink-volume 0 +1000
  # For ALSA use: config = amixer sset Master 1+
  repeat = 1
end

begin
  button = KEY_VOLUMEDOWN
  prog = irexec
  config = pactl set-sink-volume 0 -1000
  # For ALSA use: config = amixer sset Master 1-
  repeat = 1
end

begin
  button = KEY_MUTE
  prog = irexec
  config = pactl set-sink-mute 0 toggle
  # For ALSA use:
  # config = amixer sset Master mute
  # config = amixer sset Master unmute
end

