Skip to content

About

Omarchy shell plugin: toggle network adapters and switch between DHCP and static IP

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

IP config for Omarchy

A small Omarchy shell plugin for flipping network adapters between DHCP and a static IP, and for turning them off and on. It looks and behaves like the Omarchy menu, and every action works from the keyboard or with the mouse.

IP config demo

Features

  • One row per adapter (Wi-Fi and Ethernet). Each row shows the network name, and under it the adapter name, the IP address and the remaining DHCP lease time. The lease time reads 11h or 3d, and exp. if the lease has run out. If there's no address, the row shows the state instead: Off, No cable or Connecting….
  • DHCP and Static buttons on each row. The active mode is highlighted. It switches the moment you choose it, without waiting for NetworkManager. Changes go to the profile named on the row: the active one, or for a disconnected adapter its most recently used one. Choosing DHCP on a profile that's already DHCP only renews the lease.
  • Static IP in one line: 10.0.0.50/24 10.0.0.1 1.1.1.1. A missing mask means /24, and if you leave out DNS the gateway is used. The field only accepts digits, dots, / and spaces.
  • Remembers your old static IP. Switching to DHCP saves the static settings on the NetworkManager profile, whether this plugin or another tool set them. Opening Static later fills them back in.
  • Live DHCP progress under each adapter while it connects, including connections NetworkManager starts on its own, like plugging in a cable. See DHCP progress.
  • Adapters work independently. While one adapter waits on DHCP, you can still use the others.

Requirements

  • Omarchy with the Quickshell-based omarchy-shell
  • NetworkManager (nmcli)
  • gdbus (from glib2), to read saved static settings
  • python-gobject with libnm's GObject bindings, to save static settings on the profile
  • notify-send, for error notifications

These all come with a standard Omarchy install.

Install

omarchy plugin add https://github.com/fivefold3/omarchy-ip-config --enable

The first time the plugin loads, a notification offers a guided setup. Clicking it opens a terminal that asks about each step before it does anything:

  1. Add IP config to the Omarchy menu under Setup › Network.
  2. Bind SUPER + ALT + N to open it.
  3. Optional: show every DHCP packet. Requires sudo to enable; see DHCP progress.

Nothing is changed if you dismiss or ignore the notification, and you're only asked once. You can run the same setup any time:

~/.config/omarchy/plugins/io.github.fivefold3.ip-config/ip-config setup

setup --yes does steps 1 and 2 without asking, and never step 3.

Steps 1 and 2 change these files, and nothing more:

  • Setup › Network › IP config: one entry in ~/.config/omarchy/extensions/omarchy-menu.jsonc (the file is created if it doesn't exist).
  • SUPER + ALT + N: one o.bind(...) line in ~/.config/hypr/bindings.lua. If that key is already bound, it's left alone and you're told what it's bound to. If Hyprland reports a config error afterwards, the line is taken out again.

Each addition sits between two marker lines naming this plugin, so remove-shortcuts can find it and take out exactly that. Files that are symlinks or belong to another user aren't touched. The menu file is checked before and after the change, using the same rules the Omarchy menu uses to read it, and it must still hold the same entries apart from this one. Files are written through a temp file and a rename, and the write is abandoned if the file changed in the meantime.

To use another key, add a binding of your own instead:

o.bind("SUPER + N", "IP config", "omarchy-shell shell toggle io.github.fivefold3.ip-config")

If that key is already taken on your setup, call hl.unbind("SUPER + N") first.

Uninstall

Remove the menu entry and key first, then the plugin:

~/.config/omarchy/plugins/io.github.fivefold3.ip-config/ip-config remove-shortcuts
omarchy plugin remove io.github.fivefold3.ip-config

remove-shortcuts only removes the blocks between this plugin's marker lines. If you edited a block by hand, it leaves that block alone and tells you, and you can delete it yourself. If you removed the plugin first, the menu entry hides itself. Delete the io.github.fivefold3.ip-config blocks from the two files above by hand. If you added your own o.bind(...) line, delete that too.

If you turned on DHCP packet logging, turn it off again first:

~/.config/omarchy/plugins/io.github.fivefold3.ip-config/ip-config remove-logging

If you removed the plugin before doing that, the file it wrote is /etc/NetworkManager/conf.d/90-ip-config-dhcp-log.conf. Its first line names this plugin, and deleting it (as root) restores NetworkManager's default DHCP logging on the next restart.

Saved static settings stay on your NetworkManager profiles under the ip-config.static-ipv4 key. They're harmless, and other tools ignore them.

Keys

In the list:

Key Action
Enter / Space / click Turn the adapter off or on
→ / l / Static button Open the static IP prompt
← / h / DHCP button Switch to DHCP
↑ ↓ / j k Move between adapters
Esc Close

In the static IP prompt:

Key Action
Enter Apply
← → / h l Move the cursor
← / h at the start, or Esc Back to the list

The prompt opens with the adapter's current static settings, or the ones saved when it last switched to DHCP. Holding ← walks the cursor to the start without leaving the prompt.

Turning an adapter off: for Wi-Fi this switches the radio off, the same as the Wi-Fi toggle in the bar. For Ethernet it disconnects the device through NetworkManager, and it stays down until you turn it back on. Ethernet with no cable has nothing to disconnect, so it can't be toggled. Its DHCP and Static settings can still be changed, and they apply when you plug in. None of this needs root.

DHCP progress

While the menu is open, it follows NetworkManager's journal and shows DHCP progress in place of the adapter's address. That covers switches made here and connections NetworkManager starts on its own, like plugging in a cable or reconnecting. DHCP steps are often only milliseconds apart, so each one stays on screen for at least 0.6 s. When they're done, the row goes back to the address and lease time.

Out of the box you get the connection stages, e.g. Releasing old address…, Starting DHCP… and Checking for conflicts….

Optional: every packet. NetworkManager only logs the individual DHCP packets (Discover, Offer, Request, Ack) at debug level. Changing that needs root, so it only happens when you ask for it. To turn it on, say yes to it in ip-config setup, or run this once:

~/.config/omarchy/plugins/io.github.fivefold3.ip-config/ip-config setup-logging

That asks for your password, then writes /etc/NetworkManager/conf.d/90-ip-config-dhcp-log.conf and applies it immediately. The file adds DHCP4:DEBUG to NetworkManager's logging domains and changes nothing else: every other domain and the overall log level stay as they are. It carries a marker line identifying it as this plugin's. The command refuses to touch that path if it's a symlink or a file the plugin didn't write (the file written by earlier releases, 1.0.0–1.1.0, is recognised and upgraded), and it writes through a temp file so nothing is ever partially overwritten. ip-config remove-logging deletes the file under the same rules and puts DHCP4 logging back to inheriting the default. Both refuse to do anything if NetworkManager isn't answering.

When renewing an address it already had, the client skips Discover and Offer, so you'll see only Request and Ack.

Reading the journal needs membership of wheel or systemd-journal, which Omarchy users normally have. Without it, the menu shows only the stages NetworkManager reports directly, such as Releasing old address… and Checking address….

How it works

  • IpConfig.qml is the UI.
  • ip-config is a Bash script that does all the NetworkManager work. It runs on its own too:
ip-config list                  # TSV: device type enabled connection method address state lease-expiry
ip-config toggle eth0
ip-config static eth0 "10.0.0.50/24 10.0.0.1 1.1.1.1"
ip-config dhcp eth0
ip-config prefill eth0          # what the static prompt would open with
ip-config watch                 # DHCP progress for all adapters, as it happens
ip-config setup-logging         # optional, see above
ip-config remove-logging        # undo setup-logging
ip-config setup                 # guided: Setup › Network entry, SUPER + ALT + N, optional DHCP logging
ip-config remove-shortcuts      # undo the menu entry and key

static and dhcp report their stages as status<TAB>text lines while the connection comes back up. watch reports DHCP steps as event<TAB>device<TAB>text lines, where empty text means the lease is done.

Saved static settings are stored on the NetworkManager profile under the ip-config.static-ipv4 key. They're read over D-Bus and written through libnm, since nmcli can't write a profile's user data.

The overlay's open payload can name a different backend script ({"backend": "/path"}); the demo recorder uses this to run against a mock. It runs as your user, like the plugin itself, so it grants nothing that omarchy-shell IPC doesn't already.

Limitations

  • IPv4 only. IPv6 addressing and DHCPv6 aren't shown or configurable; the static prompt only accepts an IPv4 address line.
  • Wi-Fi off/on is the radio switch, the same one the bar uses. With more than one Wi-Fi adapter, they go off and on together.

Re-recording the demo

demo/mock-backend has the same interface as ip-config, but it keeps fake adapters in a scratch file, so recording never touches real networking. demo/record.sh drives the plugin on an empty workspace with wtype and records it with gpu-screen-recorder. demo/make-gif.sh crops the recording and converts it:

demo/record.sh /tmp/demo.mp4
demo/make-gif.sh /tmp/demo.mp4

License

MIT

About

Omarchy shell plugin: toggle network adapters and switch between DHCP and static IP

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages