Skip to content

Commit

Permalink
Add list support for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoB-dev committed Dec 16, 2022
1 parent 9fdfd9d commit 816759c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion wifi_password/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def get_platform() -> str:
Returns the name of the platform where the application is currently running
"""
platforms = {
'linux': constants.LINUX,
'linux1': constants.LINUX,
'linux2': constants.LINUX,
'darwin': constants.MAC,
Expand All @@ -37,7 +38,13 @@ def get_profiles() -> list:
# Command found here : https://coderwall.com/p/ghl-cg/list-known-wlans
profiles = run_command(f"defaults read ~/Library/Logs/com.apple.wifi.syncable-networks.plist | grep \" SSID\" | sed 's/^.*= \(.*\);$/\\1/' | sed 's/^\"\\(.*\)\"$/\\1/'").split('\n')
elif platform == constants.LINUX:
pass
if os.getuid() != 0:
ssid = run_command(f"sudo ls /etc/NetworkManager/system-connections/ | grep .nmconnection").split('\n')
else:
ssid = run_command(f"ls /etc/NetworkManager/system-connections/ | grep .nmconnection").split('\n')

for entry in ssid:
profiles.append(entry.split('.nmconnection')[0])
elif platform == constants.WINDOWS:
# Reference: https://www.geeksforgeeks.org/getting-saved-wifi-passwords-using-python/
# getting meta data
Expand Down

1 comment on commit 816759c

@Mariomabel
Copy link

Choose a reason for hiding this comment

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

wifi_password/utils.py

Please sign in to comment.