From 64f3113373dec17b7969463280825180c035c2bf Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Sat, 18 Jan 2025 16:12:31 -0500 Subject: [PATCH 1/6] feat: add wake on lan toggle ujust per (#1708) --- .../share/ublue-os/just/81-bazzite-fixes.just | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just index a1ca988500..28d647c4df 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just @@ -87,3 +87,44 @@ toggle-bt-mic: else echo "No changes were made." fi + +# enable or disable wake-on-lan functionality +toggle-wol: + #!/usr/bin/bash + INTERFACE=$(ip link show | awk '/state UP/ {print $2}' | tr -d ':' | grep -E '^(en|eth)') + if [[ -z "$INTERFACE" ]]; then + echo -e "${bold}No active Ethernet interface found.${normal}" + echo "Please ensure your Ethernet connection is enabled or connected." + echo "Exiting without making any changes." + exit 0 + fi + CONFIG_FILE="/etc/udev/rules.d/81-wol.rules" + WOL_STATUS=$(sudo ethtool $INTERFACE | grep "Wake-on" | awk '{print $2}') + CURRENT_STATE="Disabled" + if [[ "$WOL_STATUS" == "g" ]]; then + CURRENT_STATE="Enabled" + fi + echo "Wake-on-LAN is currently: ${bold}${CURRENT_STATE}${normal}" + echo "Enable or Disable Wake-on-LAN, or Exit without saving?" + OPTION=$(ugum choose Enable Disable Exit) + if [[ "${OPTION,,}" == "enable" ]]; then + echo "You chose to enable Wake-on-LAN." + echo "Requesting root privileges..." + sudo ethtool -s $INTERFACE wol g + if ! grep -q "$INTERFACE" "$CONFIG_FILE" 2>/dev/null; then + echo "Creating udev rule to make this setting persistent..." + echo "ACTION==\"add\", SUBSYSTEM==\"net\", NAME==\"$INTERFACE\", RUN+=\"/usr/bin/ethtool -s \$name wol g\"" | sudo tee "$CONFIG_FILE" > /dev/null + fi + echo "Wake-on-LAN has been ${green}${bold}enabled${normal}." + elif [[ "${OPTION,,}" == "disable" ]]; then + echo "You chose to disable Wake-on-LAN." + echo "Requesting root privileges..." + sudo ethtool -s $INTERFACE wol d + if [[ -f "$CONFIG_FILE" ]]; then + echo "Removing udev rule to disable persistence..." + sudo rm -f "$CONFIG_FILE" + fi + echo "Wake-on-LAN has been ${red}${bold}disabled${normal}." + else + echo "No changes were made." + fi From 282cf89384036a0c3553b6eed82688032d13bb18 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Mon, 20 Jan 2025 21:04:44 -0500 Subject: [PATCH 2/6] chore: fix just syntax post conflict merge --- .../desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just | 1 - 1 file changed, 1 deletion(-) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just index c2d9647446..5fce8f0990 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just @@ -88,7 +88,6 @@ toggle-bt-mic: echo "No changes were made." fi - # enable or disable wake-on-lan functionality toggle-wol: #!/usr/bin/bash From 6683a66b885c4fd536eaba771da05b12047bf863 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 21 Jan 2025 10:14:14 -0500 Subject: [PATCH 3/6] feat: add systemd service for persistant WOL --- .../share/ublue-os/just/81-bazzite-fixes.just | 55 ++++++++++++------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just index 5fce8f0990..67a5fcb644 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just @@ -99,34 +99,51 @@ toggle-wol: exit 0 fi CONFIG_FILE="/etc/udev/rules.d/81-wol.rules" + SERVICE_FILE="/etc/systemd/system/force-wol.service" WOL_STATUS=$(sudo ethtool $INTERFACE | grep "Wake-on" | awk '{print $2}') CURRENT_STATE="Disabled" if [[ "$WOL_STATUS" == "g" ]]; then CURRENT_STATE="Enabled" fi echo "Wake-on-LAN is currently: ${bold}${CURRENT_STATE}${normal}" - echo "Enable or Disable Wake-on-LAN, or Exit without saving?" - OPTION=$(ugum choose Enable Disable Exit) + echo "Enable, Disable Wake-on-LAN, Create Service, or Exit without saving?" + OPTION=$(ugum choose Enable Disable Create-Service Exit) if [[ "${OPTION,,}" == "enable" ]]; then - echo "You chose to enable Wake-on-LAN." - echo "Requesting root privileges..." - sudo ethtool -s $INTERFACE wol g - if ! grep -q "$INTERFACE" "$CONFIG_FILE" 2>/dev/null; then - echo "Creating udev rule to make this setting persistent..." - echo "ACTION==\"add\", SUBSYSTEM==\"net\", NAME==\"$INTERFACE\", RUN+=\"/usr/bin/ethtool -s \$name wol g\"" | sudo tee "$CONFIG_FILE" > /dev/null - fi - echo "Wake-on-LAN has been ${green}${bold}enabled${normal}." + echo "You chose to enable Wake-on-LAN." + echo "Requesting root privileges..." + sudo ethtool -s $INTERFACE wol g + if ! grep -q "$INTERFACE" "$CONFIG_FILE" 2>/dev/null; then + echo "Creating udev rule to make this setting persistent..." + echo "ACTION==\"add\", SUBSYSTEM==\"net\", NAME==\"$INTERFACE\", RUN+=\"/usr/bin/ethtool -s \$name wol g\"" | sudo tee "$CONFIG_FILE" > /dev/null + fi + echo "Wake-on-LAN has been ${green}${bold}enabled${normal}." elif [[ "${OPTION,,}" == "disable" ]]; then - echo "You chose to disable Wake-on-LAN." - echo "Requesting root privileges..." - sudo ethtool -s $INTERFACE wol d - if [[ -f "$CONFIG_FILE" ]]; then - echo "Removing udev rule to disable persistence..." - sudo rm -f "$CONFIG_FILE" - fi - echo "Wake-on-LAN has been ${red}${bold}disabled${normal}." + echo "You chose to disable Wake-on-LAN." + echo "Requesting root privileges..." + sudo ethtool -s $INTERFACE wol d + if [[ -f "$CONFIG_FILE" ]]; then + echo "Removing udev rule to disable persistence..." + sudo rm -f "$CONFIG_FILE" + fi + echo "Wake-on-LAN has been ${red}${bold}disabled${normal}." + elif [[ "${OPTION,,}" == "create-service" ]]; then + echo "You chose to create a systemd service for enabling WOL at boot." + echo "Requesting root privileges..." + sudo bash -c "cat > $SERVICE_FILE" < Date: Tue, 21 Jan 2025 10:18:29 -0500 Subject: [PATCH 4/6] fix: adjusted service option description --- .../shared/usr/share/ublue-os/just/81-bazzite-fixes.just | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just index 67a5fcb644..182c95faf1 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just @@ -126,7 +126,7 @@ toggle-wol: sudo rm -f "$CONFIG_FILE" fi echo "Wake-on-LAN has been ${red}${bold}disabled${normal}." - elif [[ "${OPTION,,}" == "create-service" ]]; then + elif [[ "${OPTION,,}" == "Make WOL service (only use this if WOL keeps turning back off after a few boots)" ]]; then echo "You chose to create a systemd service for enabling WOL at boot." echo "Requesting root privileges..." sudo bash -c "cat > $SERVICE_FILE" < Date: Tue, 21 Jan 2025 10:43:21 -0500 Subject: [PATCH 5/6] fix: revert option name change, parens breaks stuff --- .../shared/usr/share/ublue-os/just/81-bazzite-fixes.just | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just index 182c95faf1..3ba0441c53 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just @@ -126,7 +126,7 @@ toggle-wol: sudo rm -f "$CONFIG_FILE" fi echo "Wake-on-LAN has been ${red}${bold}disabled${normal}." - elif [[ "${OPTION,,}" == "Make WOL service (only use this if WOL keeps turning back off after a few boots)" ]]; then + elif [[ "${OPTION,,}" == "Create-Service" ]]; then echo "You chose to create a systemd service for enabling WOL at boot." echo "Requesting root privileges..." sudo bash -c "cat > $SERVICE_FILE" < Date: Wed, 22 Jan 2025 07:34:24 -0500 Subject: [PATCH 6/6] Update 81-bazzite-fixes.just Co-authored-by: HikariKnight <2557889+HikariKnight@users.noreply.github.com> --- .../desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just | 1 + 1 file changed, 1 insertion(+) diff --git a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just index 3ba0441c53..a232af4ff6 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just +++ b/system_files/desktop/shared/usr/share/ublue-os/just/81-bazzite-fixes.just @@ -107,6 +107,7 @@ toggle-wol: fi echo "Wake-on-LAN is currently: ${bold}${CURRENT_STATE}${normal}" echo "Enable, Disable Wake-on-LAN, Create Service, or Exit without saving?" + echo "Note: Create service if Enabling is not persistent." OPTION=$(ugum choose Enable Disable Create-Service Exit) if [[ "${OPTION,,}" == "enable" ]]; then echo "You chose to enable Wake-on-LAN."