I’ve been using the following line to determine my keyboard layout
current=`gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "imports.ui.status.keyboard.getInputSourceManager()._mruSources[0]"`
after update to gnome 45, I first had to enable unsafe mode to be able to execute that, then I started getting the following output to that command:
(false, 'SyntaxError: import declarations may only appear at top level of a module')
as i understand the reason behind this is switch to “standard JavaScript modules” in gnome. As I am not really knowledgeable in javascript, I googled a bit on what is this all about, and tried to rewrite the call to return the actual result:
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "import('resource:///org/gnome/shell/ui/status/keyboard.js').then((module)=>{module.getInputSourceManager()._mruSources[0]})"
but that does not seem to work, as I get
(true, '{}')
I’d appreciate if someone suggests a proper way to do this.