If you want a "working answer" use an indirect GUI "variable" to tell you where you are:
tell application "System Events" to text items 27 thru -1 of item 1 of (picture of every desktop as list) as string
(<= shorter but politically in-correct)
set delimOrgs to text item delimiters
set text item delimiters to {"/"}
tell application "System Events" to set BGpict to ¬
last text item of (picture of current desktop as text)
set text item delimiters to delimOrgs
return BGpict [improved: user3439894's suggestion]
… which e.g. returns "Lion.jpg"
on one of my 4 workspaces, "Sierra.jpg"
on another, which means I was using desktop 3 first and desktop 1 right now.
#!/bin/bash _/¯ osascript /Users/myComputerName/.config/bitbar/Workingspace_Desktop.app
. . . simply placed in a 3rd party's ("BitBar") plugIns folder which calls an AppleScript that withif BGname is "Sierra.jpg" then set BGname to " [ 1 ] "
etc. displays [ 1 ] or [ 2 ] or [ 3 ] or [ 4 ] in my right-side menu bar. If you read so far you will guess that ANY message can thus be displayed permanently … – Mcneal