-
Notifications
You must be signed in to change notification settings - Fork 283
CLI usage without Gnome environment
Nebulosa edited this page Apr 21, 2024
·
13 revisions
We can use gsconnect without Gnome installed, this page explains how to do it for general wayland environment.
- 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.
- 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]
For example, with waybar and hack nerd font, one can do the following steps.
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.
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"
}