Merge branch 'master' into master

This commit is contained in:
Tjark Saul 2022-10-04 16:36:21 +02:00 committed by GitHub
commit 641f9dd248
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 21 deletions

View file

@ -68,6 +68,16 @@ Status bar usage
Do you want to see how late your current train is, from the comfort of your status bar? Look no further! 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' ' '"
interval = 120
hide_when_empty = true
```
### awesomewm (+ vicious) ### awesomewm (+ vicious)
Create a custom widget which calls the widget script, and replace all newlines with spaces. Create a custom widget which calls the widget script, and replace all newlines with spaces.
@ -75,7 +85,7 @@ Create a custom widget which calls the widget script, and replace all newlines w
``` ```
myambien = wibox.widget.textbox() myambien = wibox.widget.textbox()
vicious.register(myambien, function(format, warg) 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") local out = f:read("*all")
f:close() f:close()
return { out:gsub('\n', ' ') } return { out:gsub('\n', ' ') }

View file

@ -1,4 +1,8 @@
ambient_is_ssid "WIFI@DB" "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
set train_status (curl -s https://iceportal.de/api1/rs/status) set train_status (curl -s https://iceportal.de/api1/rs/status)

View file

@ -21,6 +21,9 @@ case "SWR WiFi"
case "VirginTrainsEC-WiFi" case "VirginTrainsEC-WiFi"
set ambient_icomera_country GB set ambient_icomera_country GB
set ambient_icomera_provider "Virgin Trains East Coast" 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" case "SJ"
set ambient_icomera_country SE set ambient_icomera_country SE
set ambient_icomera_provider SJ set ambient_icomera_provider SJ
@ -29,34 +32,34 @@ case "Irish Rail - WiFi"
set ambient_icomera_provider "Irish Rail" set ambient_icomera_provider "Irish Rail"
case "THALYSNET" case "THALYSNET"
set ambient_icomera_country FR set ambient_icomera_country FR
set ambient_icomera_country Thalys set ambient_icomera_provider Thalys
end
test -n "$ambient_icomera_provider"; or exit
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
end end
if test -n $ambient_icomera_provider echo AMBIENT_ICOMERA_PROVIDER=$ambient_icomera_provider
function ambient_get_icomera_endpoint echo AMBIENT_ICOMERA_COUNTRY=$ambient_icomera_country
set url https://www.ombord.info/api/jsonp/$argv/ ambient_get_icomera_endpoint position | jq -r '"
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 '"
AMBIENT_ICOMERA_POSITION_LONGITUDE=\(.longitude) AMBIENT_ICOMERA_POSITION_LONGITUDE=\(.longitude)
AMBIENT_ICOMERA_POSITION_LATITUDE=\(.latitude) AMBIENT_ICOMERA_POSITION_LATITUDE=\(.latitude)
AMBIENT_ICOMERA_POSITION_ALTITUDE=\(.altitude) AMBIENT_ICOMERA_POSITION_ALTITUDE=\(.altitude)
AMBIENT_ICOMERA_POSITION_SPEED=\(.speed) AMBIENT_ICOMERA_POSITION_SPEED=\(.speed)
AMBIENT_ICOMERA_POSITION_SATELLITES=\(.satellites) 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_TOTAL=\(.total)
AMBIENT_ICOMERA_USERS_ONLINE=\(.online) 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_DOWNLOAD_USED=\(.data_download_used)
AMBIENT_ICOMERA_USER_DATA_UPLOAD_USED=\(.data_upload_used) AMBIENT_ICOMERA_USER_DATA_UPLOAD_USED=\(.data_upload_used)
AMBIENT_ICOMERA_USER_DATA_TOTAL_USED=\(.data_total_used) AMBIENT_ICOMERA_USER_DATA_TOTAL_USED=\(.data_total_used)
@ -73,4 +76,3 @@ AMBIENT_ICOMERA_USER_ONLINE=\(.online)
AMBIENT_ICOMERA_USER_CAP_LEVEL=\(.cap_level) AMBIENT_ICOMERA_USER_CAP_LEVEL=\(.cap_level)
AMBIENT_ICOMERA_USER_AUTHENTICATED=\(.authenticated) AMBIENT_ICOMERA_USER_AUTHENTICATED=\(.authenticated)
"' "'
end

View file

@ -3,7 +3,7 @@ function ambient_get_ssid
if test (uname) = "Darwin" if test (uname) = "Darwin"
set -g ambient_ssid (/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n 's/^ *SSID: //p') set -g ambient_ssid (/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n 's/^ *SSID: //p')
else 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
end end
echo $ambient_ssid echo $ambient_ssid

View file

@ -0,0 +1,3 @@
function ambient_resolve4
host -tA iceportal.de | sed 's/.*has address //'
end

View file

@ -0,0 +1,3 @@
if set -q AMBIENT_ICOMERA_POSITION_SPEED
echo "💨 $AMBIENT_ICOMERA_POSITION_SPEED km/h"
end