Skip to content

Commit 26a552f

Browse files
move ssh to sub_row, add ai sub_row for share
1 parent 9b48a9c commit 26a552f

8 files changed

Lines changed: 168 additions & 17 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
#Translation
4+
export TEXTDOMAINDIR="/usr/share/locale"
5+
export TEXTDOMAIN=biglinux-settings
6+
7+
# check current status
8+
check_state() {
9+
if grep 'OLLAMA_HOST=0.0.0.0' /usr/lib/systemd/system/ollama.service &>/dev/null; then
10+
echo "true"
11+
else
12+
echo "false"
13+
fi
14+
}
15+
16+
# change the state
17+
toggle_state() {
18+
new_state="$1"
19+
if [[ "$new_state" == "true" ]];then
20+
pkexec $PWD/ai/ollamaShareRun.sh "install" "$USER" "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$LANG" "$LANGUAGE"
21+
exitCode=$?
22+
else
23+
pkexec $PWD/ai/ollamaShareRun.sh "uninstall" "$USER" "$DISPLAY" "$XAUTHORITY" "$DBUS_SESSION_BUS_ADDRESS" "$LANG" "$LANGUAGE"
24+
exitCode=$?
25+
fi
26+
exit $exitCode
27+
}
28+
29+
# Executes the function based on the parameter
30+
case "$1" in
31+
"check")
32+
check_state
33+
;;
34+
"toggle")
35+
toggle_state "$2"
36+
;;
37+
"info")
38+
info
39+
;;
40+
*)
41+
echo "Use: $0 {check|toggle} [true|false]"
42+
echo " check - Check current status"
43+
echo " toggle <state> - Changes to the specified state"
44+
exit 1
45+
;;
46+
esac
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
#Translation
4+
export TEXTDOMAINDIR="/usr/share/locale"
5+
export TEXTDOMAIN=biglinux-settings
6+
7+
# Assign the received arguments to variables with clear names
8+
function="$1"
9+
originalUser="$2"
10+
userDisplay="$3"
11+
userXauthority="$4"
12+
userDbusAddress="$5"
13+
userLang="$6"
14+
userLanguage="$7"
15+
16+
# Helper function to run a command as the original user
17+
runAsUser() {
18+
# Single quotes around variables are a good security practice
19+
su "$originalUser" -c "export DISPLAY='$userDisplay'; export XAUTHORITY='$userXauthority'; export DBUS_SESSION_BUS_ADDRESS='$userDbusAddress'; export LANG='$userLang'; export LC_ALL='$userLang'; export LANGUAGE='$userLanguage'; $1"
20+
}
21+
22+
# # Creates a named pipe (FIFO) for communication with Zenity
23+
# pipePath="/tmp/ollama_share_pipe_$$"
24+
# mkfifo "$pipePath"
25+
26+
# Executes the root tasks.
27+
updateTask() {
28+
if [[ "$function" == "install" ]]; then
29+
sed -i /'WorkingDirectory=/{p;s/.*/Environment="OLLAMA_HOST=0.0.0.0"/;}' /usr/lib/systemd/system/ollama.service
30+
else
31+
sed -i '/Environment="OLLAMA_HOST=0.0.0.0"/d' /usr/lib/systemd/system/ollama.service
32+
fi
33+
exitCode=$?
34+
}
35+
updateTask #> "$pipePath"
36+
37+
# Cleans up the pipe
38+
# rm "$pipePath"
39+
40+
localIp=$(ip route get 1 | awk '{print $7; exit}')
41+
42+
# Shows the final result to the user, also with the correct theme.
43+
if [[ "$exitCode" == "0" ]] && [[ "$function" == "install" ]]; then
44+
zenityText=$"Ollama shared successfully.\nAddress: http://$localIp:11434"
45+
runAsUser "zenity --info --text=\"$zenityText\""
46+
else
47+
zenityText=$"Failed to shared Ollama!"
48+
zenity --info --text="$zenityText"
49+
fi
50+
51+
# Exits the script with the correct exit code
52+
exit $exitCode

usr/share/biglinux/biglinux-settings/ai_page.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, main_window, **kwargs):
4848
"chatai-symbolic",
4949
)
5050
# Ollama CPU
51-
self.create_row(
51+
ollama = self.create_row(
5252
ollamaServer,
5353
_("OllamaCPU"),
5454
_("Local AI server. For CPUs only."),
@@ -57,7 +57,7 @@ def __init__(self, main_window, **kwargs):
5757
info_text=_("Ollama server is running.\nAddress: http://localhost:11434"),
5858
)
5959
# Ollama Vulkan
60-
self.create_row(
60+
ollama = self.create_row(
6161
ollamaServer,
6262
_("Ollama Vulkan"),
6363
_("Local AI server. For CPUs and GPUs integrated and/or legacy."),
@@ -66,7 +66,7 @@ def __init__(self, main_window, **kwargs):
6666
info_text=_("Ollama server is running.\nAddress: http://localhost:11434"),
6767
)
6868
# Ollama AMD ROCm
69-
self.create_row(
69+
ollama = self.create_row(
7070
ollamaServer,
7171
_("Ollama AMD ROCm"),
7272
_("Local AI server. For newer AMD GPUs, starting from the 6000 series."),
@@ -75,14 +75,22 @@ def __init__(self, main_window, **kwargs):
7575
info_text=_("Ollama server is running.\nAddress: http://localhost:11434"),
7676
)
7777
# Ollama Nvidia CUDA
78-
self.create_row(
78+
ollama = self.create_row(
7979
ollamaServer,
8080
_("Ollama Nvidia CUDA"),
8181
_("Local AI server. For newer Nvidia GPUs, starting from the 2000 series."),
8282
"ollamaNvidia",
8383
"ollama-symbolic",
8484
info_text=_("Ollama server is running.\nAddress: http://localhost:11434"),
8585
)
86+
self.create_sub_row(
87+
ollamaServer,
88+
_("Share Ollama"),
89+
_("Share ollama on the local network."),
90+
"ollamaShare",
91+
"ollama-symbolic",
92+
ollama,
93+
)
8694
# Ollama LAB
8795
self.create_row(
8896
aiGui,

usr/share/biglinux/biglinux-settings/base_page.py

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,17 @@ def create_row(self, parent_group, title, subtitle_with_markup, script_name, ico
145145
parent_group.add(row)
146146
return switch
147147

148-
def create_sub_row(self, parent_group, title, subtitle_with_markup, script_name, icon_name, parent_switch: Gtk.Switch):
148+
def create_sub_row(self, parent_group, title, subtitle_with_markup, script_name, icon_name, parent_switch: Gtk.Switch, info_text: Optional[str] = None):
149149
# Cria o row (mesma lógica de create_row, mas sem retorno do switch direto)
150150
row = Adw.PreferencesRow()
151+
row._is_sub_row = True
151152

152153
main_box = Gtk.Box(
153154
orientation=Gtk.Orientation.HORIZONTAL,
154155
spacing=12,
155156
margin_top=6,
156157
margin_bottom=6,
157-
margin_start=12,
158+
margin_start=50,
158159
margin_end=12,
159160
)
160161
row.set_child(main_box)
@@ -184,6 +185,22 @@ def create_sub_row(self, parent_group, title, subtitle_with_markup, script_name,
184185
title_area.append(subtitle_label)
185186

186187
switch = Gtk.Switch(valign=Gtk.Align.CENTER)
188+
189+
if info_text:
190+
info_icon = Gtk.Image.new_from_icon_name("info")
191+
info_icon.set_pixel_size(28)
192+
info_icon.add_css_class("suggested-action")
193+
info_icon.add_css_class("symbolic-icon")
194+
info_icon.add_css_class("info-icon-blue")
195+
info_icon.set_valign(Gtk.Align.CENTER)
196+
info_icon.set_tooltip_text(info_text)
197+
198+
# Começa invisível, será controlado pelo _toggle_info_icon_visibility
199+
info_icon.set_visible(False)
200+
201+
setattr(switch, "_info_icon", info_icon)
202+
main_box.append(info_icon)
203+
187204
main_box.append(switch)
188205

189206
script_group = getattr(parent_group, "script_group", "default")
@@ -193,10 +210,10 @@ def create_sub_row(self, parent_group, title, subtitle_with_markup, script_name,
193210

194211
parent_group.add(row)
195212

196-
# Começa oculto
213+
# It starts hidden
197214
row.set_visible(False)
198215

199-
# Registra o subswitch
216+
# Register the sub-switch
200217
self.sub_switches.setdefault(parent_switch, []).append(row)
201218

202219
return switch
@@ -320,7 +337,8 @@ def sync_all_switches(self):
320337
self._toggle_info_icon_visibility(switch, False)
321338
else:
322339
row.set_sensitive(True)
323-
row.set_visible(True)
340+
if not getattr(row, "_is_sub_row", False):
341+
row.set_visible(True)
324342
row.set_tooltip_text(None)
325343
row._hidden_no_support = False
326344
switch.handler_block_by_func(self.on_switch_changed)
@@ -368,7 +386,8 @@ def sync_all_switches(self):
368386
for parent_switch, child_rows in self.sub_switches.items():
369387
parent_state = parent_switch.get_active()
370388
for child_row in child_rows:
371-
child_row.set_visible(parent_state)
389+
is_supported = not getattr(child_row, "_hidden_no_support", False)
390+
child_row.set_visible(parent_state and is_supported)
372391

373392
def on_switch_changed(self, switch, state):
374393
"""Callback executed when a user manually toggles a switch."""
@@ -400,7 +419,8 @@ def on_switch_changed(self, switch, state):
400419
# If this switch is a parent, adjust visibility of its sub‑switches
401420
if switch in self.sub_switches:
402421
for child_row in self.sub_switches[switch]:
403-
child_row.set_visible(state)
422+
is_supported = not getattr(child_row, "_hidden_no_support", False)
423+
child_row.set_visible(state and is_supported)
404424

405425
# After a successful change, refresh all switches to reflect real state
406426
self.sync_all_switches()
@@ -482,7 +502,24 @@ def _filter_group(self, group, search_text, hide_group_headers=False):
482502
continue
483503

484504
if not search_text:
485-
row.set_visible(True)
505+
if getattr(row, "_is_sub_row", False):
506+
parent_switch = None
507+
# Procura quem é o pai desta row
508+
for p_switch, children in self.sub_switches.items():
509+
if row in children:
510+
parent_switch = p_switch
511+
break
512+
513+
if parent_switch:
514+
# Visível apenas se o pai estiver ativo
515+
row.set_visible(parent_switch.get_active())
516+
else:
517+
# Fallback seguro
518+
row.set_visible(False)
519+
else:
520+
# Row normal fica sempre visível sem busca
521+
row.set_visible(True)
522+
486523
visible_count += 1
487524
else:
488525
text = self._get_row_text(row).lower()

usr/share/biglinux/biglinux-settings/devices_page.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def __init__(self, main_window, **kwargs):
4141
_("Advanced audio effects processor that improves sound quality."),
4242
"jamesdsp",
4343
"jamesdsp-symbolic",
44-
info_text=_("Ollama server is running.\nAddress: http://localhost:11434"),
4544
)
4645

4746
# Keyboard LED

usr/share/biglinux/biglinux-settings/performance_games_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, main_window, **kwargs):
7777
"stop-akonadi-server-symbolic"
7878
)
7979
# Unload S.M.A.R.T Monitor
80-
smart = self.create_row(
80+
self.create_row(
8181
performance_group,
8282
_("Unload S.M.A.R.T Monitor"),
8383
_("Disables S.M.A.R.T disk monitoring. Reduces disk I/O and CPU usage."),

usr/share/biglinux/biglinux-settings/usability/sshStart.sh renamed to usr/share/biglinux/biglinux-settings/system/sshStart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ toggle_state() {
1616
pkexec systemctl start sshd
1717
exitCode=$?
1818
else
19-
pkexec systemctl stop sshd
19+
pkexec systemctl disable --now sshd
2020
exitCode=$?
2121
fi
2222
}

usr/share/biglinux/biglinux-settings/system_page.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,20 @@ def __init__(self, main_window, **kwargs):
1616
content.append(group)
1717

1818
# sshEnable
19-
self.create_row(group,
19+
ssh = self.create_row(
20+
group,
21+
_("SSH"),
22+
_("Enable remote access via ssh."),
23+
"sshStart",
24+
"ssh-symbolic",
25+
)
26+
self.create_sub_row(
27+
group,
2028
_("SSH always on"),
2129
_("Turn on ssh remote access at boot."),
2230
"sshEnable",
23-
"ssh-symbolic"
31+
"ssh-symbolic",
32+
ssh,
2433
)
2534

2635
# fastGrub

0 commit comments

Comments
 (0)