rfkill

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rfkill reads and switches the kernel's radio kill switches through /dev/rfkill: airplane mode soft-blocks every transmitting radio class, and the state lives in the kernel, so it outlasts the shell.

Index

Constants

View Source
const DevicePath = "/dev/rfkill"

DevicePath is the kernel's rfkill control device.

View Source
const EventSize = 8

EventSize is RFKILL_EVENT_SIZE_V1, the event size the kernel reads and writes to a reader that never raised it.

Variables

AirplaneTypes are the transmitting radio classes airplane mode blocks; the receivers (GPS, FM) stay as they are.

Functions

This section is empty.

Types

type Event

type Event struct {
	Index uint32
	Type  Type
	Op    Op
	Soft  bool
	Hard  bool
}

Event is one struct rfkill_event.

func Decode

func Decode(b [EventSize]byte) Event

Decode parses one event's wire form.

func (Event) Encode

func (e Event) Encode() [EventSize]byte

Encode is the event's wire form.

type Op

type Op uint8

Op is what an event reports or asks (enum rfkill_operation).

const (
	OpAdd Op = iota
	OpDel
	OpChange
	OpChangeAll
)

The operations of linux/rfkill.h.

type Radio

type Radio struct {
	Index uint32
	Type  Type
	Soft  bool
	Hard  bool
}

Radio is one kill switch the kernel knows.

type Snapshot

type Snapshot struct {
	Radios []Radio
}

Snapshot is the kill switches at one moment.

func (Snapshot) Airplane

func (s Snapshot) Airplane() bool

Airplane reports airplane mode: there is a radio airplane mode switches and every one of them is soft-blocked.

func (Snapshot) Available

func (s Snapshot) Available() bool

Available reports a radio airplane mode switches.

type Switch

type Switch struct {
	// contains filtered or unexported fields
}

Switch is the kill switches behind one rfkill device node.

func New

func New(path string) *Switch

New is the switches behind the device node at path.

func (*Switch) Read

func (s *Switch) Read(ctx context.Context) (Snapshot, error)

Read collects the kill switches: the device queues an add event for each one to every reader that opens it.

func (*Switch) SetAirplane

func (s *Switch) SetAirplane(ctx context.Context, on bool) error

SetAirplane soft-blocks every airplane radio class, or unblocks them all.

func (*Switch) Subscribe

func (s *Switch) Subscribe(ctx context.Context) (<-chan struct{}, func() error, error)

Subscribe ticks on every event the device reports: switches added, removed or flipped by anyone. The channel closes when ctx completes or stop runs; stop closes the device, waits for the reader and reports what ended it other than the close.

type Type

type Type uint8

Type is a radio class (enum rfkill_type).

const (
	TypeAll Type = iota
	TypeWLAN
	TypeBluetooth
	TypeUWB
	TypeWiMAX
	TypeWWAN
	TypeGPS
	TypeFM
	TypeNFC
)

The radio classes of linux/rfkill.h.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL