You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
9.0KB

  1. # vim: ft=cfg
  2. #
  3. # This is the configuration file of "rifle", ranger's file executor/opener.
  4. # Each line consists of conditions and a command. For each line the conditions
  5. # are checked and if they are met, the respective command is run.
  6. #
  7. # Syntax:
  8. # <condition1> , <condition2> , ... = command
  9. #
  10. # The command can contain these environment variables:
  11. # $1-$9 | The n-th selected file
  12. # $@ | All selected files
  13. #
  14. # If you use the special command "ask", rifle will ask you what program to run.
  15. #
  16. # Prefixing a condition with "!" will negate its result.
  17. # These conditions are currently supported:
  18. # match <regexp> | The regexp matches $1
  19. # ext <regexp> | The regexp matches the extension of $1
  20. # mime <regexp> | The regexp matches the mime type of $1
  21. # name <regexp> | The regexp matches the basename of $1
  22. # path <regexp> | The regexp matches the absolute path of $1
  23. # has <program> | The program is installed (i.e. located in $PATH)
  24. # file | $1 is a file
  25. # directory | $1 is a directory
  26. # number <n> | change the number of this command to n
  27. # terminal | stdin, stderr and stdout are connected to a terminal
  28. # X | $DISPLAY is not empty (i.e. Xorg runs)
  29. #
  30. # There are also pseudo-conditions which have a "side effect":
  31. # flag <flags> | Change how the program is run. See below.
  32. # label <label> | Assign a label or name to the command so it can
  33. # | be started with :open_with <label> in ranger
  34. # | or `rifle -p <label>` in the standalone executable.
  35. # else | Always true.
  36. #
  37. # Flags are single characters which slightly transform the command:
  38. # f | Fork the program, make it run in the background.
  39. # | New command = setsid $command >& /dev/null &
  40. # r | Execute the command with root permissions
  41. # | New command = sudo $command
  42. # t | Run the program in a new terminal. If $TERMCMD is not defined,
  43. # | rifle will attempt to extract it from $TERM.
  44. # | New command = $TERMCMD -e $command
  45. # Note: The "New command" serves only as an illustration, the exact
  46. # implementation may differ.
  47. # Note: When using rifle in ranger, there is an additional flag "c" for
  48. # only running the current file even if you have marked multiple files.
  49. # mime application.x-executable, flag f = setxkbmap us;"$1";setxkbmap bepo
  50. mime application.x-executable, flag f = $1
  51. #-------------------------------------------
  52. # Websites
  53. #-------------------------------------------
  54. # Rarely installed browsers get higher priority; It is assumed that if you
  55. # install a rare browser, you probably use it. Firefox/konqueror/w3m on the
  56. # other hand are often only installed as fallback browsers.
  57. ext x?html?, has qutebrowser, X, flag f = qutebrowser -- "$@"
  58. ext x?html?, has firefox, X, flag f = firefox -- "$@"
  59. ext x?html?, has chromium, X, flag f = chromium -- "$@"
  60. ext x?html?, has elinks, terminal = elinks "$@"
  61. ext x?html?, has links2, terminal = links2 "$@"
  62. ext x?html?, has links, terminal = links "$@"
  63. ext x?html?, has lynx, terminal = lynx -- "$@"
  64. ext x?html?, has w3m, terminal = w3m "$@"
  65. #-------------------------------------------
  66. # Misc
  67. #-------------------------------------------
  68. ext 1 = man "$1"
  69. ext s[wmf]c, has zsnes, X = zsnes "$1"
  70. ext nes, has fceux, X = fceux "$1"
  71. ext exe = wine "$1"
  72. name ^[mM]akefile$ = make
  73. ext epub, X, flag f = ebook-viewer "$1"
  74. mime ^text, flag f, ext srt = gaupol "$@"
  75. #--------------------------------------------
  76. # Code
  77. #-------------------------------------------
  78. ext py = python -- "$1"
  79. ext pl = perl -- "$1"
  80. ext rb = ruby -- "$1"
  81. ext sh, flag t = sh -- "$1"
  82. ext php = php -- "$1"
  83. #--------------------------------------------
  84. # database
  85. #--------------------------------------------
  86. ext db, X, flag f = sqliteman "$@"
  87. #--------------------------------------------
  88. # Audio without X
  89. #-------------------------------------------
  90. mime ^audio|ogg$, terminal, has mplayer = mplayer -- "$@"
  91. mime ^audio|ogg$, terminal, has mplayer2 = mplayer2 -- "$@"
  92. ext midi?, terminal, has wildmidi = wildmidi -- "$@"
  93. #--------------------------------------------
  94. # Video/Audio with a GUI
  95. #-------------------------------------------
  96. mime ^video|audio, has gmplayer, X, flag f = gmplayer -- "$@"
  97. mime ^video|audio, has smplayer, X, flag f = smplayer "$@"
  98. mime ^video, has mplayer2, X, flag f = mplayer2 -- "$@"
  99. mime ^video, has mplayer2, X, flag f = mplayer2 -fs -- "$@"
  100. mime ^video, has mplayer, X, flag f = mplayer -- "$@"
  101. mime ^video, has mplayer, X, flag f = mplayer -fs -- "$@"
  102. mime ^video|audio, has mpv, X, flag f = popup Ranger && mpv -- "$@"
  103. mime ^video|audio, has totem, X, flag f = totem -- "$@"
  104. mime ^video|audio, has totem, X, flag f = totem --fullscreen -- "$@"
  105. ext play, has mpv, X, flag f = popup Ranger && mpv --playlist="$@"
  106. #--------------------------------------------
  107. # Video without X:
  108. #-------------------------------------------
  109. mime ^video, terminal, !X, has mplayer2 = mplayer2 -- "$@"
  110. mime ^video, terminal, !X, has mplayer = mplayer -- "$@"
  111. #-------------------------------------------
  112. # Image Viewing:
  113. #-------------------------------------------
  114. mime ^image, ext svg, has inkscape, X, flag f = inkscape -- "$@"
  115. mime ^image, has eog, X, flag f = eog -- "$@"
  116. mime ^image, has sxiv, X, flag f = sxiv -absf "$@"
  117. mime ^image, has feh, X, flag f = feh -- "$@"
  118. mime ^image, has mirage, X, flag f = mirage -- "$@"
  119. mime ^image, has gimp, X, flag f = gimp -- "$@"
  120. ext xcf, X, flag f = gimp -- "$@"
  121. #-------------------------------------------
  122. # Documents
  123. #-------------------------------------------
  124. ext pdf, has zathura, X, flag f = zathura -- "$@"
  125. ext docx?, has catdoc, terminal = catdoc -- "$@" | "$PAGER"
  126. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric|csv, has gnumeric, X, flag f = gnumeric -- "$@"
  127. ext sxc|xlsx?|xlt|xlw|gnm|gnumeric|csv, has kspread, X, flag f = kspread -- "$@"
  128. ext doc, X, flag f = env WINEPREFIX=/home/maxx/.office wine start /ProgIDOpen Word.Document.8 "$@"
  129. ext docx, X, flag f = env WINEPREFIX=/home/maxx/.office wine start /ProgIDOpen Word.Document.12 "$@"
  130. ext xls, X, flag f = env WINEPREFIX=/home/maxx/.office wine start /ProgIDOpen Excel.Sheet.8 "$@"
  131. ext xlsx, X, flag f = env WINEPREFIX=/home/maxx/.office wine start /ProgIDOpen Excel.Sheet.12 "$@"
  132. ext ppt, X, flag f = env WINEPREFIX=/home/maxx/.office wine start /ProgIDOpen Powerpoint.Show.8 "$@"
  133. ext pptx, X, flag f = env WINEPREFIX=/home/maxx/.office wine start /ProgIDOpen Powerpoint.Show.12 "$@"
  134. ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric|csv, has libreoffice, X, flag f = libreoffice "$@"
  135. ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric|csv, has soffice, X, flag f = soffice "$@"
  136. ext od[dfgpst]|docx?|sxc|xlsx?|xlt|xlw|gnm|gnumeric|csv, has ooffice, X, flag f = ooffice "$@"
  137. ext djvu, has evince, X, flag f = evince -- "$@"
  138. #-------------------------------------------
  139. # Archives
  140. #-------------------------------------------
  141. # This requires atool
  142. ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has aunpack = atool -X . -- "$@"
  143. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has aunpack = atool -X . -- "$@"
  144. ext 7z|ace|ar|arc|bz2?|cab|cpio|cpt|deb|dgc|dmg|gz, has als = als -- "$@" | "$PAGER"
  145. ext iso|jar|msi|pkg|rar|shar|tar|tgz|xar|xpi|xz|zip, has als = als -- "$@" | "$PAGER"
  146. # Fallback:
  147. ext tar|gz, has tar = tar vvtf "$@" | "$PAGER"
  148. ext tar|gz, has tar = tar vvxf "$@"
  149. #-------------------------------------------
  150. # Misc
  151. #-------------------------------------------
  152. label wallpaper, number 11, mime ^image, X = feh --bg-scale "$1"
  153. label wallpaper, number 12, mime ^image, X = feh --bg-tile "$1"
  154. label wallpaper, number 13, mime ^image, X = feh --bg-center "$1"
  155. label wallpaper, number 14, mime ^image, X = feh --bg-fill "$1"
  156. # Define the editor + pager as last action
  157. !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = ask
  158. label editor, X, flag t, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@"
  159. label pager, X, flag t, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$PAGER" -- "$@"
  160. mime ^text, X, flag t, label editor = "$EDITOR" -- "$@"
  161. mime ^text, X, flag t, label pager = "$PAGER" -- "$@"
  162. !mime ^text, X, flag t, label editor, ext R|xml|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@"
  163. !mime ^text, X, flag t, label pager, ext R|xml|tex|py|pl|rb|sh|php = "$PAGER" -- "$@"
  164. !mime ^text, X, flag t, editor = "$EDITOR" -- "$@"
  165. !mime ^text, X, flag t, editor = "$PAGER" -- "$@"
  166. label editor, terminal, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@"
  167. label pager, terminal, !mime ^text, !ext xml|csv|tex|py|pl|rb|sh|php = "$PAGER" -- "$@"
  168. mime ^text, terminal, label editor = "$EDITOR" -- "$@"
  169. mime ^text, terminal, label pager = "$PAGER" -- "$@"
  170. !mime ^text, terminal, label editor, ext R|xml|tex|py|pl|rb|sh|php = "$EDITOR" -- "$@"
  171. !mime ^text, terminal, label pager, ext R|xml|tex|py|pl|rb|sh|php = "$PAGER" -- "$@"
  172. !mime ^text, terminal, editor = "$EDITOR" -- "$@"
  173. !mime ^text, terminal, editor = "$PAGER" -- "$@"