« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/loop-play.js5
-rwxr-xr-xsrc/play.js20
2 files changed, 22 insertions, 3 deletions
diff --git a/src/loop-play.js b/src/loop-play.js
index 62e67fd..2fa7da7 100644
--- a/src/loop-play.js
+++ b/src/loop-play.js
@@ -719,7 +719,8 @@ module.exports = async function startLoopPlay(
     useConverterOptions = true,
     disablePlaybackStatus = false,
     startTrack = null,
-    trackDisplayFile = null
+    trackDisplayFile = null,
+    statusLineTemplate = undefined
   }
 ) {
   // Looping play function. Takes a playlist and an object containing general
@@ -764,7 +765,7 @@ module.exports = async function startLoopPlay(
 
   const playController = new PlayController({
     player, playlist, historyController, downloadController,
-    trackDisplayFile
+    trackDisplayFile, statusLineTemplate
   })
 
   Object.assign(playController, {useConverterOptions})
diff --git a/src/play.js b/src/play.js
index dd49afe..e9b5231 100755
--- a/src/play.js
+++ b/src/play.js
@@ -77,9 +77,12 @@ async function main(args) {
   // keybinding files.
   let mayTrustShellCommands = true
 
-  // The file to output the playlist path to the current file.
+  // The file to write the playlist path of the current file to.
   let trackDisplayFile
 
+  // The (custom) status line template string.
+  let statusLineTemplate
+
   const keybindings = [
     [['space'], 'togglePause'],
     [['left'], 'seek', -5],
@@ -381,6 +384,20 @@ async function main(args) {
 
     '-hide-playback-status': util => util.alias('-disable-playback-status'),
 
+    '-status-line': function(util) {
+      // --status-line <string>  (alias: --playback-status-line, --status, etc)
+      // Sets the text to be shown in status line. This is a "template" string,
+      // which means you can use text such as %timeLeft% and %duration% and
+      // these will be replaced with appropriate values.)
+
+      statusLineTemplate = util.nextArg()
+      console.log('Using custom status line:', statusLineTemplate)
+    },
+
+    '-playback-status': util => util.alias('-status-line'),
+    '-playback-status-line': util => util.alias('-status-line'),
+    '-status': util => util.alias('-status-line'),
+
     '-track-display-file': async function(util) {
       // --track-display-file  (alias: --display-track-file)
       // Sets the file to output the current track's path to every time a new
@@ -482,6 +499,7 @@ async function main(args) {
         willUseConverterOptions === null && shouldUseConverterOptions
       ),
       disablePlaybackStatus,
+      statusLineTemplate,
       startTrack,
       trackDisplayFile
     })