Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ bind = Super+Shift+Alt, R, exec, /usr/share/sleex/scripts/record-script.sh --ful
##! Session
# bind = Super, L, exec, hyprlock # Lock session
bind = Super, L, global, quickshell:lockScreen # Lock session
bind = Super, M, exec, ~/.config/hypr/custom/scripts/Insomnia.sh # Toggle Insomnia Mode

#!
##! Window management
Expand Down
3 changes: 2 additions & 1 deletion src/share/sleex/modules/common/Config.qml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ Singleton {
property string avatarPath: "file:///usr/share/sleex/assets/logo/1024px/white.png"
property string userDesc: "Today is a good day to have a good day!"
property bool enableWeather: false
property string weatherLocation: "" // :)
property string weatherLocation: ""
property string customDNS: ""
}

property JsonObject dock: JsonObject {
Expand Down
52 changes: 36 additions & 16 deletions src/share/sleex/modules/settings/Privacy.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,37 @@ ContentPage {

ContentSection {
title: "Policies"

ContentSubsectionLabel {
text: "AI"
}

ConfigSelectionArray {
currentValue: Config.options.policies.ai
onSelected: newValue => {
Config.options.policies.ai = newValue;
}
options: [
{
displayName: "No",
value: 0
},
{
displayName: "Yes",
value: 1
},
{
displayName: "Local only",
value: 2
}
{ displayName: "No", value: 0 },
{ displayName: "Yes", value: 1 },
{ displayName: "Local only", value: 2 }
]
}
}

ContentSection {
title: "Weather"

ContentSubsectionLabel {
text: "Weather"
}
ConfigSwitch {
id: weatherSwitch
text: "Enabled"
checked: Config.options.dashboard.enableWeather
onClicked: checked = !checked;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't remove that. This makes the whole switch+label clickable, instead of just the switch.

onCheckedChanged: Config.options.dashboard.enableWeather = checked
StyledToolTip { content: "The weather module uses your approximate location based on your local IP. It uses the https://wttr.in provider." }

StyledToolTip {
content: "The weather module uses your approximate location based on your local IP. It uses the https://wttr.in provider."
}
}

MaterialTextField {
Expand All @@ -59,4 +56,27 @@ ContentPage {
}
}
}

ContentSection {
title: "DNS"


MaterialTextField {
id: customDNS
Layout.fillWidth: true
placeholderText: "DNS Server"
text: Config.options.dashboard.customDNS
wrapMode: TextEdit.Wrap

onEditingFinished: {
// Save the value
Config.options.dashboard.customDNS = text

// Run the Python script
Quickshell.execDetached(["python", "/usr/share/sleex/scripts/set-dns.py"])

}
}

}
}
78 changes: 78 additions & 0 deletions src/share/sleex/scripts/set-dns.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks AI generated, is it the case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

I made set-dns.sh

But I didn't know how to execute it from the .qml file

So I shoved the set-dns.sh in AI and converted it to set-dns.py

Then used the similar format from /usr/share/sleex/modules/dashboard/quickToggles/IdleInhibitor.qml

but idk why it still isn't working

Copy link
Member

@LeVraiArdox LeVraiArdox Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it doesn't works ? In that case open the PR as draft and request a review when it's working

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script itself works
Just how to toggle from within settings is the issue
I'll draft now

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env python3
import subprocess
import json
import os
import getpass

# Path to the settings JSON
CONFIG_FILE = os.path.expanduser("~/.sleex/settings.json")

def run_cmd(cmd, capture_output=True):
"""Run a shell command and return its output."""
result = subprocess.run(cmd, shell=True, text=True,
capture_output=capture_output)
if result.returncode != 0:
return None
return result.stdout.strip()

def get_custom_dns():
"""Read customDNS from settings.json."""
if not os.path.exists(CONFIG_FILE):
print(f"Settings file not found: {CONFIG_FILE}")
return None
try:
with open(CONFIG_FILE, "r") as f:
config = json.load(f)
# Navigate to dashboard.customDNS
dns = config.get("dashboard", {}).get("customDNS", "").strip()
if dns:
return dns
else:
print("customDNS is empty in settings.json")
return None
except Exception as e:
print(f"Failed to read settings.json: {e}")
return None

def main():
dns_server = get_custom_dns()
if not dns_server:
print("Please set a custom DNS in ~/.sleex/settings.json under dashboard.customDNS")
return

# Detect the active connection
active_conn_cmd = "nmcli -t -f NAME,DEVICE connection show --active | head -n1 | cut -d: -f1"
active_conn = run_cmd(active_conn_cmd)
if not active_conn:
print("No active network connection found.")
return

print(f"Setting DNS {dns_server} for connection '{active_conn}'...")

# Check connection type
con_type_cmd = f"nmcli -g connection.type connection show '{active_conn}'"
con_type = run_cmd(con_type_cmd)

# If Wi-Fi, check for PSK
if con_type == "wifi":
psk_cmd = f"nmcli -g 802-11-wireless-security.psk connection show '{active_conn}'"
psk = run_cmd(psk_cmd)
if not psk:
psk = getpass.getpass("Wi-Fi password not found. Please enter it: ")
subprocess.run(f"nmcli connection modify '{active_conn}' wifi-sec.psk '{psk}'", shell=True)

# Set the DNS and ignore auto DNS
set_dns_cmd = f"nmcli connection modify '{active_conn}' ipv4.dns '{dns_server}' ipv4.ignore-auto-dns yes"
if run_cmd(set_dns_cmd) is None:
print(f"Failed to set DNS {dns_server} for connection '{active_conn}'.")
return

# Reactivate the connection
subprocess.run(f"nmcli connection down '{active_conn}'", shell=True)
subprocess.run(f"nmcli connection up '{active_conn}'", shell=True)

print("DNS updated successfully.")
subprocess.run("nmcli dev show | grep DNS", shell=True)

if __name__ == "__main__":
main()