Hi everyone!
I was trying to auto power-on/off my WIFI connection on Manjaro Gnome at set times (something like some Androids have) but I do not find any solution.
Any hint?
Thank You
Hi @alimurgia,
If you know the command, you could create a systemd timer unit, both for disabling and enabling the device.
I don’t know if this is the best way, or even a good way, but it is
Hope this helps!
nmcli
You can write a small bash script.
On KDE, you could set an event in KAlarm to run the script to enable/disable it.
You need to schedule nmcli radio wifi off
and nmcli radio wifi on
You could use a cron job, or a simple alarm to run a script.
You could also set a timer in your terminal… I don’t use Gnome though.
I would do this:
#!/bin/bash
commands () {
echo WiFi OFF
sleep 1; date +"It's now %R" | cowthink
echo "How long until turning off WiFi?"; read TIME
echo $TIME set!; sleep $TIME; nmcli radio wifi off
}
export -f commands
konsole -e "bash -c 'commands'"
Make it executable, and drag a shortcut to a panel.
Or, move it to your PATH and call it ‘Timer-WifiOFF’.
You could do a similar script with no timer…
#!/bin/bash
nmcli radio wifi off
Here’s now KAlarm sets my RTCWake to wake up my computer in the morning before my wakeup alarm…
Or combine this with a systemd timer. They’re quite easy to make.
best solution ever!
Or you can do it like I like doing it. Manually creating the file:
https://wiki.archlinux.org/title/Systemd/Timers
It might sound complicated, but it’s actually easier than cron jobs according to me.
Yay - well not quite so GUI as I’d hoped… but I got it sorted.
- Created script ~/bin/rtcwake0600.sh
#!/bin/bash
echo MYPASSWORD | sudo -S rtcwake -m no -l -t $(date +%s -d 'tomorrow 0559')
- Mkdir and CD
~/.config/systemd/user/
rtcwake.service
[Unit]
Description=A job to set rtcwake with a systemd timer
[Service]
Type=simple
ExecStart=/home/ben/bin/rtcwake0600.sh
[Install]
WantedBy=default.target
rtcwake.timer
[Unit]
Description=Schedule rtcwake every morning
RefuseManualStart=no
RefuseManualStop=no
[Timer]
#Execute job if it missed a run due to machine being off
Persistent=true
#Run 120 seconds after boot for the first time
OnBootSec=120
#Run every 30 minutes
OnUnitActiveSec=1800
#File describing job to execute
Unit=rtcwake.service
[Install]
WantedBy=timers.target
And because these timers are kind of invisible, I added a conky entry:
rtcwake: ${execi 3500 ~/.local/bin/sudo-rtccheck.sh}
And the script to check and display is:
#!/bin/bash
echo MYPASSWORD | sudo -S rtcwake -m show -l -v |rg alarm: | cut -c 12-30
ROFL quite a bit of messing, and much worse than having a simple option to click the clock - set an alarm/timer, select an option to wake up the machine if it’s off etc… but oddly satisfying
How did it go with the Wifi?