Repository navigation
Focus mode
Focus mode is for games and for heavy creative work: 3D, CAD, video and music. While a program like that is open, the background work the desktop does waits. File indexing, backups, updates, the ad-block list fetch and the like stop using the processor and the disk. Ollama, the language model behind Ask derisk, stops and gives its memory back. When the last of those programs closes, everything carries on where it stopped.
nixos/modules/focus.nix sets it up, and losos-focus
(src/losos-focus) does the work.
GameMode is the switch. A program asks GameMode for focus while it runs, and GameMode turns focus mode on for the first program and off when the last one exits. A program asks in one of three ways:
-
derisk asks for every window whose program's desktop entry is in the category
Game,3DGraphics,Engineering,AudioVideoEditing,SequencerorMidi. That covers games, Blender, FreeCAD, Kdenlive, Ardour and LMMS, for example. -
Many games ask by themselves. In Steam, set a game's launch options to
gamemoderun %command%. Lutris and Heroic have a GameMode switch. -
Anything else runs under
gamemoderun:$ gamemoderun krita
losos-focus start and losos-focus stop turn it on and off by hand, and
losos-focus status says whether it is on.
While GameMode is on it also sets the processor to its fastest governor, as it does on any Linux system. The screen still blanks and locks when nobody touches the computer, unless the program itself asks it not to, as video players and most games do.
| Waits | How |
|---|---|
| Your file index, backups, the LosOS boxes browser, the active-user count, Danube's captive portal watch, the Mac downloads watch | frozen in your background.slice
|
| Updates, the ad-block lists, firmware metadata, log rotation, SSD trimming, Podman's cleanup | frozen in the system's losos-background.slice
|
| The timers that start that work | stopped, and started again afterwards |
| Ollama | stopped, and started again afterwards |
Frozen work is held at the instruction it had reached, by the kernel's cgroup freezer. It keeps its memory and resumes as if nothing happened. An update download frozen for long enough that the server hangs up is cleared away and tried again at the next update.
systemd refuses to start anything in a frozen slice, so the timers stop too, rather than fire and fail. Once started again, the update, backup and ad-block timers run straight away if their time came meanwhile. Starting one of those services by hand while focus mode is on fails with "Cannot start frozen unit".
The desktop itself does not wait, since it draws the program's window. It already costs next to nothing while nothing else on the screen changes: mcsapi's compositor redraws only what changed.
If you log out while focus mode is on, it turns off. GameMode goes with
your session, so the system unit that holds focus,
losos-focus@<you>.service, also watches for your session to end. Updates
never stay frozen until the next boot because of a session that closed.
With two people signed in, the system's work waits while either of them is in focus mode.
polkit lets the person signed in at the computer start and stop their own
losos-focus@<name>.service and no other unit. pm's rule refuses every
other systemd action to anyone but pm. GameMode's helpers that set the
processor governor and the split-lock slowdown are allowed to the same
person. Its GPU overclocking helper is not.
Generated from docs/ in the repository at every change; edit the pages there, since an edit made here is overwritten.
- LosOS Desktop
- Building
- When something goes wrong
- Reporting a problem
-
The system
- Everything systemd, and the exceptions
- Virtual machine desktop
- Peripherals in machines of their own
- The network machine
- The files machine
- The portal machine
- Where the OS lives
- Hibernation
- Hardware and NVIDIA
- Boot loader and boot screen
- Secure Boot
- The installer
- The Windows installer
- Trying it in quickemu
- First-boot setup
- Signing in
- Security keys and smart cards
- More than one person
- Company accounts
- Releases and GHCR
- The memory allocator
- The security report
- Kernel hardening
- Schizo mode
- VPN
-
Desktop and apps
- GTK and Qt on a phone
- One icon theme
- Danube
- System-wide ad blocking
- The terminal
- Ask derisk
- The Store
- The Agent
- Active users and the choice screens
- LosOS boxes
- Windows app support
- The gaming machine
- Focus mode
- Android app support
- macOS app support
- arm64 macOS machines
- App windows
- Backups to a LosOS box
- Screenshots
- Building blocks
- Phones
- History and gaps