From 3647cef82a2ae2e9676eb9e04f12d4666281ba39 Mon Sep 17 00:00:00 2001 From: Erika Date: Fri, 11 Mar 2022 18:59:26 +0000 Subject: [PATCH 01/10] ambient_get_ssid: don't truncate SSID at first space --- functions.d/ambient_get_ssid.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.d/ambient_get_ssid.fish b/functions.d/ambient_get_ssid.fish index cfc949b..bdc9684 100644 --- a/functions.d/ambient_get_ssid.fish +++ b/functions.d/ambient_get_ssid.fish @@ -3,7 +3,7 @@ function ambient_get_ssid if test (uname) = "Darwin" set -g ambient_ssid (/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n 's/^ *SSID: //p') else - set -g ambient_ssid (iw dev | grep ssid | awk '{print $2}') + set -g ambient_ssid (iw dev | grep ssid | sed -n 's/^\s*ssid //p') end end echo $ambient_ssid From 913cc85e1aa8f34dfcfb8c179cab171c704d808c Mon Sep 17 00:00:00 2001 From: Erika Date: Fri, 11 Mar 2022 19:00:34 +0000 Subject: [PATCH 02/10] trains/_icomera: add TransPennine Express to list of recognized SSIDs --- ambient.d/trains/_icomera.fish | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ambient.d/trains/_icomera.fish b/ambient.d/trains/_icomera.fish index 9bf9640..e34fc98 100644 --- a/ambient.d/trains/_icomera.fish +++ b/ambient.d/trains/_icomera.fish @@ -18,6 +18,9 @@ case "SWR WiFi" case "VirginTrainsEC-WiFi" set ambient_icomera_country GB set ambient_icomera_provider "Virgin Trains East Coast" +case "TPE Wi-Fi" + set ambient_icomera_country GB + set ambient_icomera_provider "TransPennine Express" case "SJ" set ambient_icomera_country SE set ambient_icomera_provider SJ From 2e01f6552e28cf06551dce2b02fb20eb4c698c87 Mon Sep 17 00:00:00 2001 From: Erika Date: Fri, 11 Mar 2022 19:22:28 +0000 Subject: [PATCH 03/10] trains/_icomera: add rudimentary widget --- widgets.d/trains/_icomera.fish | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 widgets.d/trains/_icomera.fish diff --git a/widgets.d/trains/_icomera.fish b/widgets.d/trains/_icomera.fish new file mode 100644 index 0000000..68f7023 --- /dev/null +++ b/widgets.d/trains/_icomera.fish @@ -0,0 +1,3 @@ +if set -q AMBIENT_ICOMERA_POSITION_SPEED + echo "💨 $AMBIENT_ICOMERA_POSITION_SPEED km/h" +end From fbf798ab505ea25bac784cc56620f9357c4df402 Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 20 Jul 2022 09:45:33 +0200 Subject: [PATCH 04/10] Thalys is a provider, not a country - for now :P --- ambient.d/trains/_icomera.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ambient.d/trains/_icomera.fish b/ambient.d/trains/_icomera.fish index e34fc98..311a1b9 100644 --- a/ambient.d/trains/_icomera.fish +++ b/ambient.d/trains/_icomera.fish @@ -32,7 +32,7 @@ case "WIFIonICE" set ambient_icomera_provider "Deutsche Bahn" case "THALYSNET" set ambient_icomera_country FR - set ambient_icomera_country Thalys + set ambient_icomera_provider Thalys end if test -n $ambient_icomera_provider From 12c3bcd8932feccaec4ebe695b0370653d086499 Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 20 Jul 2022 09:47:01 +0200 Subject: [PATCH 05/10] icomera: exit on non-icomera WiFi instead of if-guarding --- ambient.d/trains/_icomera.fish | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/ambient.d/trains/_icomera.fish b/ambient.d/trains/_icomera.fish index 311a1b9..3c9cf31 100644 --- a/ambient.d/trains/_icomera.fish +++ b/ambient.d/trains/_icomera.fish @@ -34,32 +34,32 @@ case "THALYSNET" set ambient_icomera_country FR set ambient_icomera_provider Thalys end +test -n "$ambient_icomera_provider"; or exit -if test -n $ambient_icomera_provider - function ambient_get_icomera_endpoint - set url https://www.ombord.info/api/jsonp/$argv/ +function ambient_get_icomera_endpoint + set url https://www.ombord.info/api/jsonp/$argv/ - if test (uname) = "Darwin" - curl -s $url | tail -c +2 | ghead -c -3 - else - curl -s $url | tail -c +2 | head -c -3 - end + if test (uname) = "Darwin" + curl -s $url | tail -c +2 | ghead -c -3 + else + curl -s $url | tail -c +2 | head -c -3 end +end - echo AMBIENT_ICOMERA_PROVIDER=$ambient_icomera_provider - echo AMBIENT_ICOMERA_COUNTRY=$ambient_icomera_country - ambient_get_icomera_endpoint position | jq -r '" +echo AMBIENT_ICOMERA_PROVIDER=$ambient_icomera_provider +echo AMBIENT_ICOMERA_COUNTRY=$ambient_icomera_country +ambient_get_icomera_endpoint position | jq -r '" AMBIENT_ICOMERA_POSITION_LONGITUDE=\(.longitude) AMBIENT_ICOMERA_POSITION_LATITUDE=\(.latitude) AMBIENT_ICOMERA_POSITION_ALTITUDE=\(.altitude) AMBIENT_ICOMERA_POSITION_SPEED=\(.speed) AMBIENT_ICOMERA_POSITION_SATELLITES=\(.satellites) "' - ambient_get_icomera_endpoint users | jq -r '" +ambient_get_icomera_endpoint users | jq -r '" AMBIENT_ICOMERA_USERS_TOTAL=\(.total) AMBIENT_ICOMERA_USERS_ONLINE=\(.online) "' - ambient_get_icomera_endpoint user | jq -r '" +ambient_get_icomera_endpoint user | jq -r '" AMBIENT_ICOMERA_USER_DATA_DOWNLOAD_USED=\(.data_download_used) AMBIENT_ICOMERA_USER_DATA_UPLOAD_USED=\(.data_upload_used) AMBIENT_ICOMERA_USER_DATA_TOTAL_USED=\(.data_total_used) @@ -76,4 +76,3 @@ AMBIENT_ICOMERA_USER_ONLINE=\(.online) AMBIENT_ICOMERA_USER_CAP_LEVEL=\(.cap_level) AMBIENT_ICOMERA_USER_AUTHENTICATED=\(.authenticated) "' -end From 02917089e532ff2291ed9167932efa238821cb37 Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 20 Jul 2022 09:47:25 +0200 Subject: [PATCH 06/10] use DE_ICE rather than _icomera for WIFIonICE --- ambient.d/trains/_icomera.fish | 3 --- 1 file changed, 3 deletions(-) diff --git a/ambient.d/trains/_icomera.fish b/ambient.d/trains/_icomera.fish index 3c9cf31..df8ef9a 100644 --- a/ambient.d/trains/_icomera.fish +++ b/ambient.d/trains/_icomera.fish @@ -27,9 +27,6 @@ case "SJ" case "Irish Rail - WiFi" set ambient_icomera_country IE set ambient_icomera_provider "Irish Rail" -case "WIFIonICE" - set ambient_icomera_country DE - set ambient_icomera_provider "Deutsche Bahn" case "THALYSNET" set ambient_icomera_country FR set ambient_icomera_provider Thalys From a19c3ea93c33a5a7f6f8b48c2e6ee4a8e45d3f99 Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 20 Jul 2022 09:50:09 +0200 Subject: [PATCH 07/10] DE_ICE: once in a blue moon, an ICE is on time, and there's no .navigationChange --- ambient.d/trains/DE_ICE.fish | 1 - 1 file changed, 1 deletion(-) diff --git a/ambient.d/trains/DE_ICE.fish b/ambient.d/trains/DE_ICE.fish index 3665945..182cdf7 100644 --- a/ambient.d/trains/DE_ICE.fish +++ b/ambient.d/trains/DE_ICE.fish @@ -13,7 +13,6 @@ AMBIENT_DE_ICE_LATITUDE=\(.latitude) AMBIENT_DE_ICE_LONGITUDE=\(.longitude) AMBIENT_DE_ICE_SERVER_TIME=\(.serverTime / 1000 | round | tostring | strptime("%s") | todate) AMBIENT_DE_ICE_WAGON_CLASS=\(.wagonClass) -AMBIENT_DE_ICE_NAVIGATION_CHANGE=\(.navigationChange | strptime("%Y-%m-%d-%H-%M-%S") | todate) AMBIENT_DE_ICE_TRAIN_TYPE=\(.trainType) "' From 3385cfae5ab02ff24efa5b58e880f88822952d4a Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 20 Jul 2022 10:08:52 +0200 Subject: [PATCH 08/10] README: add i3status-rs --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1da9fe..6c89390 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,14 @@ Status bar usage Do you want to see how late your current train is, from the comfort of your status bar? Look no further! +### i3status-rs + +``` +[[block]] +block = "custom" +command = "/path/to/ambient/ambient-widgets | tr '\n' ' '" +``` + ### awesomewm (+ vicious) Create a custom widget which calls the widget script, and replace all newlines with spaces. @@ -75,7 +83,7 @@ Create a custom widget which calls the widget script, and replace all newlines w ``` myambien = wibox.widget.textbox() vicious.register(myambien, function(format, warg) - local f = io.popen("echo -n ' '; " .. os.getenv("HOME") .. "/Projects/src/github.com/liclac/ambient/ambient-widgets") + local f = io.popen("echo -n ' '; " .. os.getenv("HOME") .. "/path/to/ambient/ambient-widgets") local out = f:read("*all") f:close() return { out:gsub('\n', ' ') } From a7766bdd7e53e156e4d5b4da9bd40b37720aa9ef Mon Sep 17 00:00:00 2001 From: embr Date: Wed, 20 Jul 2022 10:36:58 +0200 Subject: [PATCH 09/10] README: i3s-rs example updates every 10s by default --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6c89390..a8568f6 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ Do you want to see how late your current train is, from the comfort of your stat [[block]] block = "custom" command = "/path/to/ambient/ambient-widgets | tr '\n' ' '" +interval = 120 +hide_when_empty = true ``` ### awesomewm (+ vicious) From f81be85d503ff57c871fee9a707c46040c069b94 Mon Sep 17 00:00:00 2001 From: embr Date: Tue, 4 Oct 2022 13:30:11 +0200 Subject: [PATCH 10/10] DE_ICE: Add support for WIFI@DB SSID --- ambient.d/trains/DE_ICE.fish | 6 +++++- functions.d/ambient_resolve4.fish | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 functions.d/ambient_resolve4.fish diff --git a/ambient.d/trains/DE_ICE.fish b/ambient.d/trains/DE_ICE.fish index 182cdf7..f3147ea 100644 --- a/ambient.d/trains/DE_ICE.fish +++ b/ambient.d/trains/DE_ICE.fish @@ -1,4 +1,8 @@ -ambient_is_ssid "WIFIonICE"; or exit +ambient_is_ssid "WIFIonICE" "WIFI@DB"; or exit + +# Some ICEs use the SSID "WIFI@DB", but that's also used at stations in Germany. +# We can tell if we're on a train if iceportal.de resolves to a private IP addr. +string match '172.*' (ambient_resolve4 iceportal.de) >/dev/null; or exit curl -s https://iceportal.de/api1/rs/status | jq -r '" AMBIENT_DE_ICE_CONNECTION=\(.connection) diff --git a/functions.d/ambient_resolve4.fish b/functions.d/ambient_resolve4.fish new file mode 100644 index 0000000..5dfd758 --- /dev/null +++ b/functions.d/ambient_resolve4.fish @@ -0,0 +1,3 @@ +function ambient_resolve4 + host -tA iceportal.de | sed 's/.*has address //' +end