This repository was archived by the owner on Jan 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
203 lines (182 loc) · 7.22 KB
/
__init__.py
File metadata and controls
203 lines (182 loc) · 7.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# -*- coding: utf-8 -*-
# Copyright (c) 2026 Ruben Lagerwerf
import subprocess
from pathlib import Path
from albert import *
md_iid = '4.0'
md_version = '1.0.0'
md_name = 'FreeRDP'
md_description = 'Launch FreeRDP sessions'
md_license = 'MIT'
md_url = 'https://github.com/RubenLWF/albert-freerdp'
md_authors = ['@RubenLWF']
md_maintainers = ['@RubenLWF']
md_bin_dependencies = ["xfreerdp3"]
class Plugin(PluginInstance, TriggerQueryHandler):
hostname: str = ''
username: str = ''
password: str = ''
domain: str = ''
floatbar_enabled: bool = False
dynamic_resolution_enabled: bool = False
clipboard_sharing_enabled: bool = False
multimon_enabled: bool = False
logo_path: Path
def __init__(self):
PluginInstance.__init__(self)
TriggerQueryHandler.__init__(self)
# Load settings from config
self.hostname = self.readConfig('hostname', str) or ''
self.username = self.readConfig('username', str) or ''
self.password = self.readConfig('password', str) or ''
self.domain = self.readConfig('domain', str) or ''
self.floatbar_enabled = self.readConfig('floatbar_enabled', bool) if self.readConfig('floatbar_enabled', bool) is not None else False
self.dynamic_resolution_enabled = self.readConfig('dynamic_resolution_enabled', bool) if self.readConfig('dynamic_resolution_enabled', bool) is not None else False
self.clipboard_sharing_enabled = self.readConfig('clipboard_sharing_enabled', bool) if self.readConfig('clipboard_sharing_enabled', bool) is not None else False
self.multimon_enabled = self.readConfig('multimon_enabled', bool) if self.readConfig('multimon_enabled', bool) is not None else False
# Get the icon path
plugin_dir = Path(__file__).parent
self.logo_path = plugin_dir / 'logo.png'
def defaultTrigger(self):
return 'rdp '
def configWidget(self):
return [
{
'type': 'lineedit',
'label': 'Server hostname',
'property': 'hostname',
'widget_properties': {
'placeholderText': 'Enter your server hostname'
}
},
{
'type': 'lineedit',
'label': 'Domain',
'property': 'domain',
'widget_properties': {
'placeholderText': 'Enter your domain'
}
},
{
'type': 'lineedit',
'label': 'Username',
'property': 'username',
'widget_properties': {
'placeholderText': 'Enter your username'
}
},
{
'type': 'lineedit',
'label': 'Password',
'property': 'password',
'widget_properties': {
'placeholderText': 'Enter your password',
'echoMode': 2 # Password mode
}
},
{
'type': 'checkbox',
'label': 'Enable floatbar',
'property': 'floatbar_enabled'
},
{
'type': 'checkbox',
'label': 'Enable dynamic resolution',
'property': 'dynamic_resolution_enabled'
},
{
'type': 'checkbox',
'label': 'Enable clipboard sharing',
'property': 'clipboard_sharing_enabled'
},
{
'type': 'checkbox',
'label': 'Enable multi-monitor support',
'property': 'multimon_enabled'
}
]
def __setattr__(self, name, value):
# Save config when settings are updated
if name == 'hostname':
super().__setattr__(name, value)
self.writeConfig('hostname', value)
elif name == 'username':
super().__setattr__(name, value)
self.writeConfig('username', value)
elif name == 'password':
super().__setattr__(name, value)
self.writeConfig('password', value)
elif name == 'domain':
super().__setattr__(name, value)
self.writeConfig('domain', value)
elif name == 'floatbar_enabled':
super().__setattr__(name, value)
self.writeConfig('floatbar_enabled', value)
elif name == 'dynamic_resolution_enabled':
super().__setattr__(name, value)
self.writeConfig('dynamic_resolution_enabled', value)
elif name == 'clipboard_sharing_enabled':
super().__setattr__(name, value)
self.writeConfig('clipboard_sharing_enabled', value)
elif name == 'multimon_enabled':
super().__setattr__(name, value)
self.writeConfig('multimon_enabled', value)
else:
super().__setattr__(name, value)
def handleTriggerQuery(self, query):
user_input = query.string.strip().lower()
items = []
def settings_valid():
return all([
self.hostname,
self.username,
self.password,
self.domain
])
if settings_valid():
if 'connect'.startswith(user_input) or 'up'.startswith(user_input) or not user_input:
def connect_rdp():
cmd = [
'xfreerdp3',
f'/v:{self.hostname}',
f'/u:{self.username}',
f'/p:{self.password}',
f'/d:{self.domain}'
]
if self.floatbar_enabled:
cmd.append('/floatbar:show:always')
if self.dynamic_resolution_enabled:
cmd.append('/dynamic-resolution')
if self.clipboard_sharing_enabled:
cmd.append('/clipboard:direction-to:all')
if self.multimon_enabled:
cmd.append('/multimon')
subprocess.Popen(
cmd,
start_new_session=True
)
items.append(
StandardItem(
id='freerdp-connect',
text='Connect via FreeRDP',
subtext=f'Launch a FreeRDP session to {self.hostname}',
icon_factory=lambda: makeImageIcon(str(self.logo_path)),
actions=[
Action(
'connect',
'Connect',
connect_rdp
)
]
)
)
else:
items.append(
StandardItem(
id='freerdp-invalid-settings',
text='Configure FreeRDP',
subtext='Configure all required settings in the plugin settings',
icon_factory=lambda: makeImageIcon(str(self.logo_path))
)
)
query.add(items)