CLI usage without Gnome environment - GSConnect/gnome-shell-extension-gsconnect GitHub Wiki
We can use gsconnect without Gnome installed, this page explains how to do it for general wayland environment.
Preparations
- Build
libgnome-volume-control, which is a subproject ofgnome-shellbut can be built independently; - Install ydotool and add current user to the
inputgroup, and start its service:systemctl start --user ydotool.service; - Install
wtypeandwl-clipboard; - Install
gjs, which is the runtime ofgsconnect.
Install gsconnect
- Clone this repo;
- Build and install it:
meson build,ninja -C build install-zip; - For systemd, make the
.servicefile for user:~/.config/systemd/user/gsconnect.serviceor/usr/lib/systemd/user/gsconnect.service:
[Unit]
Description=GSConnect CLI
Documentation=https://github.com/GSConnect/gnome-shell-extension-gsconnect/wiki/CLI-usage-without-Gnome-environment
PartOf=graphical-session.target
After=graphical-session.target
Requisite=graphical-session.target
[Service]
ExecStart=/usr/share/gnome-shell/extensions/[email protected]/service/daemon.js
Restart=on-failure
[Install]
WantedBy=graphical-session.target
- If
gsconnect.serviceis located at/usr/lib/systemd/user/gsconnect.servicegsconnectcan be loaded automatically throughdbusby request thought indicator described below or manually on clickRefreshbutton ingsconnect-preferences.
Hint: to see status started service by dbus, you should use
systemctl status --user dbus-:[email protected]
Indicator of gsconnect
For example, with waybar and hack nerd font, one can do the following steps.
Script to fetch gsconnect status
Save the following script to ~/.config/waybar/gsconnect-status.py.
#! python3
from pydbus import SessionBus
import json
session_bus = SessionBus()
proxy_gsconnect = session_bus.get(
'org.gnome.Shell.Extensions.GSConnect',
'/org/gnome/Shell/Extensions/GSConnect')
gsconnect = proxy_gsconnect[
'org.freedesktop.DBus.ObjectManager']
waybar = {'text': "", 'tooltip': "", "class": "GSdevices", "types": ""}
icons = {'smartphone-symbolic': "", "tablet-symbolic": "",
'tv-symbolic': "", 'computer-symbolic': ""}
types = []
devices = gsconnect.GetManagedObjects()
for dev in devices:
devinfo = devices[dev]['org.gnome.Shell.Extensions.GSConnect.Device']
if devinfo['Connected']:
if devinfo['Paired']:
types.append(devinfo['Type'])
waybar['text'] += icons[devinfo['IconName']] + ' '
waybar['tooltip'] += devinfo['Name'] + '\n'
if not devinfo['Paired']:
types.append(devinfo['Type'])
waybar['text'] += ' ' + ' '
waybar['tooltip'] += devinfo['Name'] + '\n'
waybar['types'] = '+'.join(types)
for key in waybar:
waybar[key] = waybar[key].strip()
print(json.dumps(waybar))
Install pydbus and test the above script to ensure that there is no problem.
Add waybar module
In this step, we assume that you know how to config waybar custom module. If not, see the waybar manual page for instructions. See the examplar config.
Add waybar the custom module:
"custom/gsconnect" : {
"format": "{}",
"escape": true,
"exec": "python3 $HOME/.config/waybar/gsconnect-status.py",
"return-type": "json",
"tooltip": "{tooltip}",
"interval": 30,
"on-click": "/usr/share/gnome-shell/extensions/[email protected]/gsconnect-preferences"
}