-
Notifications
You must be signed in to change notification settings - Fork 259
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-shell
but can be built independently; - Install ydotool and add current user to the
input
group, and start its service:systemctl start --user ydotool.service
; - Install
wtype
andwl-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
.service
file for user:~/.config/systemd/user/gsconnect.service
or/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.service
is located at/usr/lib/systemd/user/gsconnect.service
gsconnect
can be loaded automatically throughdbus
by request thought indicator described below or manually on clickRefresh
button 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"
}