Skip to content

Commit 7a4e7aa

Browse files
committed
Add connectivity management features to GNOME environment
- Introduced new command type for connectivity management. - Implemented commands for managing network devices, including WiFi, Bluetooth, and Airplane mode. - Added support for enabling/disabling WiFi and Bluetooth, checking their statuses, and managing hotspots. - Updated documentation with examples for new connectivity commands. - Enhanced the assistant's command processing to handle connectivity-related inputs. - Created a new DBus service for managing connectivity features in the GNOME environment.
1 parent 63b54eb commit 7a4e7aa

11 files changed

Lines changed: 1204 additions & 0 deletions

File tree

dbus/gnome/connectivity.go

Lines changed: 657 additions & 0 deletions
Large diffs are not rendered by default.

dbus/gnome/gnome.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ func NewEnvironment() (*Environment, error) {
5151
core.CapabilityClipboard,
5252
core.CapabilityAppearanceManagement,
5353
core.CapabilitySoundManagement,
54+
core.CapabilityConnectivityManagement,
5455
}
5556

5657
// Create base environment
@@ -109,6 +110,8 @@ func (e *Environment) ExecuteCommand(ctx context.Context, cmd *core.Command) (*c
109110
return e.executeAppearanceCommand(ctx, cmd)
110111
case core.CommandTypeSound:
111112
return e.executeSoundCommand(ctx, cmd)
113+
case core.CommandTypeConnectivity:
114+
return e.executeConnectivityCommand(ctx, cmd)
112115
default:
113116
return nil, fmt.Errorf("unsupported command type: %s", cmd.Type)
114117
}

docs/examples.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,31 @@ lumo desktop:"show all sound devices"
323323
lumo desktop:"get current volume level"
324324
lumo desktop:"set default sound device to alsa_output.pci-0000_00_1f.3.analog-stereo"
325325

326+
# Control connectivity settings (GNOME)
327+
lumo desktop:"show all network devices"
328+
lumo desktop:"turn on WiFi"
329+
lumo desktop:"turn off WiFi"
330+
lumo desktop:"check WiFi status"
331+
lumo desktop:"enable Bluetooth"
332+
lumo desktop:"disable Bluetooth"
333+
lumo desktop:"check Bluetooth status"
334+
lumo desktop:"turn on airplane mode"
335+
lumo desktop:"turn off airplane mode"
336+
lumo desktop:"check airplane mode status"
337+
lumo desktop:"create a WiFi hotspot with name 'MyHotspot'"
338+
lumo desktop:"create a WiFi hotspot with name 'MyHotspot' and password 'securepass'"
339+
lumo desktop:"turn off WiFi hotspot"
340+
lumo desktop:"check hotspot status"
341+
326342
# AI-powered natural language commands
327343
lumo desktop:"I want to close all Firefox windows and then open a new terminal"
328344
lumo desktop:"Could you please minimize all my windows and then lock my screen?"
329345
lumo desktop:"First open Firefox, then maximize it, and finally play some music"
330346
lumo desktop:"Switch to dark mode and set my background to night-sky.jpg"
331347
lumo desktop:"Increase the volume to 80 percent and then play some music"
348+
lumo desktop:"Turn off WiFi and Bluetooth to save battery"
349+
lumo desktop:"Enable airplane mode and then set volume to 0"
350+
lumo desktop:"Create a hotspot named 'LumoShare' with password 'lumo1234'"
332351
```
333352

334353

internal/assistant/ai_client.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Valid command types:
4545
- media (for media operations)
4646
- appearance (for appearance settings)
4747
- sound (for sound settings)
48+
- connectivity (for network connectivity settings)
4849
4950
Valid actions for window:
5051
- close (close a window)
@@ -97,6 +98,21 @@ Valid actions for sound:
9798
- list-devices (list available sound devices)
9899
- set-default-device (set default sound device)
99100
101+
Valid actions for connectivity:
102+
- list-devices (list all network devices)
103+
- enable-wifi (enable WiFi)
104+
- disable-wifi (disable WiFi)
105+
- wifi-status (get WiFi status)
106+
- enable-bluetooth (enable Bluetooth)
107+
- disable-bluetooth (disable Bluetooth)
108+
- bluetooth-status (get Bluetooth status)
109+
- enable-airplane-mode (enable airplane mode)
110+
- disable-airplane-mode (disable airplane mode)
111+
- airplane-mode-status (get airplane mode status)
112+
- enable-hotspot (enable WiFi hotspot)
113+
- disable-hotspot (disable WiFi hotspot)
114+
- hotspot-status (get WiFi hotspot status)
115+
100116
Examples:
101117
- "Close Firefox window" -> "window:close:firefox"
102118
- "Launch Terminal" -> "application:launch:gnome-terminal"
@@ -113,6 +129,11 @@ Examples:
113129
- "Unmute the microphone" -> "sound:set-input-mute:false"
114130
- "Show sound devices" -> "sound:list-devices:"
115131
- "Set microphone volume to 75 percent" -> "sound:set-input-volume:75"
132+
- "Show all network devices" -> "connectivity:list-devices:"
133+
- "Turn on WiFi" -> "connectivity:enable-wifi:"
134+
- "Turn off Bluetooth" -> "connectivity:disable-bluetooth:"
135+
- "Check airplane mode status" -> "connectivity:airplane-mode-status:"
136+
- "Create a WiFi hotspot with name MyHotspot" -> "connectivity:enable-hotspot:MyHotspot"
116137
117138
Only output the structured format, nothing else. Do not include newlines or multiple commands.
118139
`, input)

internal/assistant/assistant.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,19 @@ func (a *Assistant) GetSupportedCommands() []string {
8989
"sound:get-input-mute",
9090
"sound:list-devices",
9191
"sound:set-default-device <device-id>",
92+
"connectivity:list-devices",
93+
"connectivity:enable-wifi",
94+
"connectivity:disable-wifi",
95+
"connectivity:wifi-status",
96+
"connectivity:enable-bluetooth",
97+
"connectivity:disable-bluetooth",
98+
"connectivity:bluetooth-status",
99+
"connectivity:enable-airplane-mode",
100+
"connectivity:disable-airplane-mode",
101+
"connectivity:airplane-mode-status",
102+
"connectivity:enable-hotspot <ssid> [password]",
103+
"connectivity:disable-hotspot",
104+
"connectivity:hotspot-status",
92105
}
93106
}
94107

@@ -126,5 +139,18 @@ func (a *Assistant) GetCommandExamples() []string {
126139
"Mute the microphone",
127140
"Show all sound devices",
128141
"Get current volume level",
142+
"Show all network devices",
143+
"Turn on WiFi",
144+
"Turn off WiFi",
145+
"Check WiFi status",
146+
"Enable Bluetooth",
147+
"Disable Bluetooth",
148+
"Check Bluetooth status",
149+
"Turn on airplane mode",
150+
"Turn off airplane mode",
151+
"Check airplane mode status",
152+
"Create a WiFi hotspot with name 'MyHotspot'",
153+
"Turn off WiFi hotspot",
154+
"Check hotspot status",
129155
}
130156
}
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
package assistant
2+
3+
import (
4+
"strings"
5+
6+
"github.com/agnath18K/lumo/internal/core"
7+
)
8+
9+
// handleListNetworkDevices handles the "list network devices" command
10+
func (p *Processor) handleListNetworkDevices(input string) (*core.Command, error) {
11+
return &core.Command{
12+
Type: core.CommandTypeConnectivity,
13+
Action: "list-devices",
14+
Target: "",
15+
RawInput: input,
16+
}, nil
17+
}
18+
19+
// handleEnableWifi handles the "enable wifi" command
20+
func (p *Processor) handleEnableWifi(input string) (*core.Command, error) {
21+
return &core.Command{
22+
Type: core.CommandTypeConnectivity,
23+
Action: "enable-wifi",
24+
Target: "",
25+
RawInput: input,
26+
}, nil
27+
}
28+
29+
// handleDisableWifi handles the "disable wifi" command
30+
func (p *Processor) handleDisableWifi(input string) (*core.Command, error) {
31+
return &core.Command{
32+
Type: core.CommandTypeConnectivity,
33+
Action: "disable-wifi",
34+
Target: "",
35+
RawInput: input,
36+
}, nil
37+
}
38+
39+
// handleWifiStatus handles the "wifi status" command
40+
func (p *Processor) handleWifiStatus(input string) (*core.Command, error) {
41+
return &core.Command{
42+
Type: core.CommandTypeConnectivity,
43+
Action: "wifi-status",
44+
Target: "",
45+
RawInput: input,
46+
}, nil
47+
}
48+
49+
// handleEnableBluetooth handles the "enable bluetooth" command
50+
func (p *Processor) handleEnableBluetooth(input string) (*core.Command, error) {
51+
return &core.Command{
52+
Type: core.CommandTypeConnectivity,
53+
Action: "enable-bluetooth",
54+
Target: "",
55+
RawInput: input,
56+
}, nil
57+
}
58+
59+
// handleDisableBluetooth handles the "disable bluetooth" command
60+
func (p *Processor) handleDisableBluetooth(input string) (*core.Command, error) {
61+
return &core.Command{
62+
Type: core.CommandTypeConnectivity,
63+
Action: "disable-bluetooth",
64+
Target: "",
65+
RawInput: input,
66+
}, nil
67+
}
68+
69+
// handleBluetoothStatus handles the "bluetooth status" command
70+
func (p *Processor) handleBluetoothStatus(input string) (*core.Command, error) {
71+
return &core.Command{
72+
Type: core.CommandTypeConnectivity,
73+
Action: "bluetooth-status",
74+
Target: "",
75+
RawInput: input,
76+
}, nil
77+
}
78+
79+
// handleEnableAirplaneMode handles the "enable airplane mode" command
80+
func (p *Processor) handleEnableAirplaneMode(input string) (*core.Command, error) {
81+
return &core.Command{
82+
Type: core.CommandTypeConnectivity,
83+
Action: "enable-airplane-mode",
84+
Target: "",
85+
RawInput: input,
86+
}, nil
87+
}
88+
89+
// handleDisableAirplaneMode handles the "disable airplane mode" command
90+
func (p *Processor) handleDisableAirplaneMode(input string) (*core.Command, error) {
91+
return &core.Command{
92+
Type: core.CommandTypeConnectivity,
93+
Action: "disable-airplane-mode",
94+
Target: "",
95+
RawInput: input,
96+
}, nil
97+
}
98+
99+
// handleAirplaneModeStatus handles the "airplane mode status" command
100+
func (p *Processor) handleAirplaneModeStatus(input string) (*core.Command, error) {
101+
return &core.Command{
102+
Type: core.CommandTypeConnectivity,
103+
Action: "airplane-mode-status",
104+
Target: "",
105+
RawInput: input,
106+
}, nil
107+
}
108+
109+
// handleEnableHotspot handles the "enable hotspot" command
110+
func (p *Processor) handleEnableHotspot(input string) (*core.Command, error) {
111+
// Extract SSID and password from the input
112+
ssid := ""
113+
password := ""
114+
115+
// Look for SSID in the input
116+
if strings.Contains(input, "ssid") || strings.Contains(input, "name") {
117+
parts := strings.Split(input, "ssid")
118+
if len(parts) > 1 {
119+
ssidPart := parts[1]
120+
ssidPart = strings.TrimSpace(ssidPart)
121+
if strings.HasPrefix(ssidPart, ":") || strings.HasPrefix(ssidPart, "=") {
122+
ssidPart = strings.TrimSpace(strings.TrimPrefix(strings.TrimPrefix(ssidPart, ":"), "="))
123+
}
124+
// Extract the SSID (may be in quotes)
125+
if strings.Contains(ssidPart, "'") {
126+
ssidParts := strings.Split(ssidPart, "'")
127+
if len(ssidParts) > 1 {
128+
ssid = ssidParts[1]
129+
}
130+
} else if strings.Contains(ssidPart, "\"") {
131+
ssidParts := strings.Split(ssidPart, "\"")
132+
if len(ssidParts) > 1 {
133+
ssid = ssidParts[1]
134+
}
135+
} else {
136+
// Take the first word as the SSID
137+
words := strings.Fields(ssidPart)
138+
if len(words) > 0 {
139+
ssid = words[0]
140+
}
141+
}
142+
}
143+
} else if strings.Contains(input, "name") {
144+
parts := strings.Split(input, "name")
145+
if len(parts) > 1 {
146+
namePart := parts[1]
147+
namePart = strings.TrimSpace(namePart)
148+
if strings.HasPrefix(namePart, ":") || strings.HasPrefix(namePart, "=") {
149+
namePart = strings.TrimSpace(strings.TrimPrefix(strings.TrimPrefix(namePart, ":"), "="))
150+
}
151+
// Extract the name (may be in quotes)
152+
if strings.Contains(namePart, "'") {
153+
nameParts := strings.Split(namePart, "'")
154+
if len(nameParts) > 1 {
155+
ssid = nameParts[1]
156+
}
157+
} else if strings.Contains(namePart, "\"") {
158+
nameParts := strings.Split(namePart, "\"")
159+
if len(nameParts) > 1 {
160+
ssid = nameParts[1]
161+
}
162+
} else {
163+
// Take the first word as the name
164+
words := strings.Fields(namePart)
165+
if len(words) > 0 {
166+
ssid = words[0]
167+
}
168+
}
169+
}
170+
}
171+
172+
// Look for password in the input
173+
if strings.Contains(input, "password") {
174+
parts := strings.Split(input, "password")
175+
if len(parts) > 1 {
176+
passwordPart := parts[1]
177+
passwordPart = strings.TrimSpace(passwordPart)
178+
if strings.HasPrefix(passwordPart, ":") || strings.HasPrefix(passwordPart, "=") {
179+
passwordPart = strings.TrimSpace(strings.TrimPrefix(strings.TrimPrefix(passwordPart, ":"), "="))
180+
}
181+
// Extract the password (may be in quotes)
182+
if strings.Contains(passwordPart, "'") {
183+
passwordParts := strings.Split(passwordPart, "'")
184+
if len(passwordParts) > 1 {
185+
password = passwordParts[1]
186+
}
187+
} else if strings.Contains(passwordPart, "\"") {
188+
passwordParts := strings.Split(passwordPart, "\"")
189+
if len(passwordParts) > 1 {
190+
password = passwordParts[1]
191+
}
192+
} else {
193+
// Take the first word as the password
194+
words := strings.Fields(passwordPart)
195+
if len(words) > 0 {
196+
password = words[0]
197+
}
198+
}
199+
}
200+
}
201+
202+
// If no SSID was found, use a default one
203+
if ssid == "" {
204+
ssid = "LumoHotspot"
205+
}
206+
207+
// Create the command
208+
cmd := &core.Command{
209+
Type: core.CommandTypeConnectivity,
210+
Action: "enable-hotspot",
211+
Target: ssid,
212+
Arguments: make(map[string]interface{}),
213+
RawInput: input,
214+
}
215+
216+
// Add password if provided
217+
if password != "" {
218+
cmd.Arguments["password"] = password
219+
}
220+
221+
return cmd, nil
222+
}
223+
224+
// handleDisableHotspot handles the "disable hotspot" command
225+
func (p *Processor) handleDisableHotspot(input string) (*core.Command, error) {
226+
return &core.Command{
227+
Type: core.CommandTypeConnectivity,
228+
Action: "disable-hotspot",
229+
Target: "",
230+
RawInput: input,
231+
}, nil
232+
}
233+
234+
// handleHotspotStatus handles the "hotspot status" command
235+
func (p *Processor) handleHotspotStatus(input string) (*core.Command, error) {
236+
return &core.Command{
237+
Type: core.CommandTypeConnectivity,
238+
Action: "hotspot-status",
239+
Target: "",
240+
RawInput: input,
241+
}, nil
242+
}

0 commit comments

Comments
 (0)