G15 Show Tune

Amarok 2.x Scripts

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

1
Score 58.0%
Description:

A simple script for Amarok 2.0 to display the current song title, artist and track time using the Logitech G15 keyboard display.

G15 daemon has to be running before you attempt to use this script.

This script has been now merged with Robert Riemann's G15 Amarok Plugin Plus (http://www.kde-apps.org/content/show.php/G15+Amarok+Plugin+Plus?content=76743) and officially replaces it.

The 2.3 release was put together completely by Robert Riemann, with the patches from Alex Richardson and Lambert Belkiss. Thank you guys and sorry for the slow turnaround time from my side - my own G15 is broken atm.
Last changelog:

9 years ago

2010-12-30: Version 2.3
* Fixed the text encoding for Latin-1 encoded tags (patch by Alex Richardson)
* Fixed wrong song duration due amarok api change (patch by Lambert Belkiss)
* Show alert message in the case of g15composer not found in $PATH

2009-03-10: Version 2.2
* Fixed the text encoding for Latin-1 encoded tags
* Code cleanups, fixed up the spec file, fixed changelog
* This script is now official successor of the G15 Amarok Plugin Plus

2009-03-09: Version 2.1
* Changed encoding for the displayed text from ISO-8859-1 to IBM 850.

2009-03-07: Version 2.0
* Fixes from Robert Riemann, now it starts the composer automatically, more fancy display, merged with his
G15 Amarok Plugin Plus (http://www.kde-apps.org/content/show.php/G15+Amarok+Plugin+Plus?content=76743)

2008-11-02: Version 1.0
* Initial release

arichardson

9 years ago

This should fix some chars not being displayed properly (i.e. German Umlauts)



diff -U 3 -H -d -r -N -- G15_Show_Tune/main.js G15_Show_Tune_upd/main.js
--- G15_Show_Tune/main.js 2010-08-18 15:58:40.053998954 +0200
+++ G15_Show_Tune_upd/main.js 2010-08-18 15:56:14.000000000 +0200
@@ -50,24 +50,6 @@
return result;
}

-function convertCP437( string )
-{
- //string = "�rzte";
-
- // convert original Latin1 text to Unicode
- codecLatin1 = new QTextCodec.codecForName(new QByteArray("ISO 8859-1"));
- unicode_str = codecLatin1.toUnicode(new QByteArray(string));
-
- // now transcode Unicode to IBM 850/CP437
- codec850 = new QTextCodec.codecForName(new QByteArray("IBM 850"));
- output = codec850.fromUnicode(unicode_str).toString();
-
- // Amarok.alert(t.readAll());
- return output;
-}
-// Amarok.alert( convertCP437( "�rzte" ) ); // Just an convertion check
-
-
function startComposer()
{
if(!composerProcess)
@@ -145,14 +127,14 @@
var rating = trackinfo.rating;
var filetype = trackinfo.type;
var bitrate = trackinfo.bitrate;
- var result = "MC 1\n" +
+ var result = "MC 1\n" +
"TO 2 2 1 0 \"Track \"\n" +
- "TO 31 2 2 0 \"" + convertCP437( title.substring(pos_t, pos_t + 16)) + "\"\n" +
+ "TO 31 2 2 0 \"" + title.substring(pos_t, pos_t + 16) + "\"\n" +
"DB 0 11 159 11 1 " + currentTime + " " + totalTime + " 1\n" +
"TO 2 15 1 0 \"Band \"\n" +
- "TO 31 15 2 0 \"" + convertCP437( artist.substring(pos_b, pos_b + 16)) + "\"\n" +
+ "TO 31 15 2 0 \"" + artist.substring(pos_b, pos_b + 16) + "\"\n" +
"TO 2 24 1 0 \"Album \"\n" +
- "TO 31 24 2 0 \"" + convertCP437( album.substring(pos_a, pos_a + 16))+ "\"\n" +
+ "TO 31 24 2 0 \"" + album.substring(pos_a, pos_a + 16) + "\"\n" +
"DL 1 32 158 32 1\n" +
"TO 2 34 1 0 \"" + time + "\"\n" +
"TO 2 34 1 1 \"rating: " + rating + "\"\n" +
@@ -160,7 +142,8 @@
"PB 0 0 159 42\n" +
"MC 0";
amarok_stream.writeString("PC 0\n");
- amarok_stream.writeString(result + "\n");
+ amarok_stream.writeString(result);
+ amarok_stream.writeString("\n");
amarok_stream.flush();
// Amarok.alert(trackinfo);
} else {
@@ -195,6 +178,7 @@
amarok_pipe = new QFile(amarok_pipe_name);
amarok_pipe.open(new QIODevice.OpenMode(QIODevice.WriteOnly));
amarok_stream = new QTextStream(amarok_pipe);
+amarok_stream.setCodec(QTextCodec.codecForName(new QByteArray("IBM 850")));

// set up timer
timer = new QTimer();

Report

iss

10 years ago

If g15composer is not present it hangs whole amarok. There should be some check for g15composer and warning if it's not found.

Nice script anyway :)

Report

belkiss

10 years ago

Hello, here is a small patch for your script (it seems the total time is returned in ms now)

--- G15_Show_Tune/main.js 2009-03-10 01:10:36.000000000 +0100
+++ main.js 2009-10-17 11:24:52.000000000 +0200
@@ -131,9 +131,9 @@
}
last_a = album;
var currentTime = Amarok.Engine.trackPosition();
- var totalTime = trackinfo.length;
+ var totalTime = trackinfo.length / 1000;
var track_pos = getTime(currentTime);
- var tot_time = getTime(trackinfo.length);
+ var tot_time = getTime(totalTime);
if(totalTime == 0)
{
currentTime = 1;


Here is a link on paste.to
http://www.paste.to/v/kjb3ul1b

Thank you for the app !
belkiss

Report

9 years ago

2010-12-30: Version 2.3
* Fixed the text encoding for Latin-1 encoded tags (patch by Alex Richardson)
* Fixed wrong song duration due amarok api change (patch by Lambert Belkiss)
* Show alert message in the case of g15composer not found in $PATH

2009-03-10: Version 2.2
* Fixed the text encoding for Latin-1 encoded tags
* Code cleanups, fixed up the spec file, fixed changelog
* This script is now official successor of the G15 Amarok Plugin Plus

2009-03-09: Version 2.1
* Changed encoding for the displayed text from ISO-8859-1 to IBM 850.

2009-03-07: Version 2.0
* Fixes from Robert Riemann, now it starts the composer automatically, more fancy display, merged with his
G15 Amarok Plugin Plus (http://www.kde-apps.org/content/show.php/G15+Amarok+Plugin+Plus?content=76743)

2008-11-02: Version 1.0
* Initial release

12345678910
1
product-maker neverendingo Feb 22 2011 9 excellent
product-maker Base: 4 x 5.0 Ratings
alerich
Nov 29 2009
File (click to download) Version Description Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
2.3
updated Jan 01 2011
added Nov 02 2008
downloads 24h
0
mediaviews 24h 0
pageviews 24h 0
System Tags addon