main 6af0a61

kernel.go RawHistoryFolder

1package packages
2
3import "errors"
4
5// KernelVariant represents available kernel choices
6type KernelVariant int
7
8const (
9	// KernelStable is the stable Linux kernel
10	KernelStable KernelVariant = iota
11
12	// KernelZen is the linux-zen kernel
13	KernelZen
14
15	// KernelLTS is the linux-lts (long-term support) kernel
16	KernelLTS
17
18	// KernelHardened is the hardened kernel with security focus
19	KernelHardened
20
21	// KernelCachyOS is the CachyOS optimized kernel
22	KernelCachyOS
23)
24
25// String returns the kernel package name
26func (k KernelVariant) String() string {
27	switch k {
28	case KernelZen:
29		return "linux-zen"
30	case KernelLTS:
31		return "linux-lts"
32	case KernelHardened:
33		return "linux-hardened"
34	case KernelCachyOS:
35		return "linux-cachyos"
36	default:
37		return "linux"
38	}
39}
40
41// IsStable returns true if kernel is stable
42func (k KernelVariant) IsStable() bool {
43	return k == KernelStable
44}
45
46// IsLTS returns true if kernel is long-term support
47func (k KernelVariant) IsLTS() bool {
48	return k == KernelLTS
49}
50
51// IsHardened returns true if kernel has hardening
52func (k KernelVariant) IsHardened() bool {
53	return k == KernelHardened
54}
55
56// Kernel is an immutable value object for kernel selection
57type Kernel struct {
58	variant KernelVariant
59}
60
61// NewKernel creates a new Kernel value object
62func NewKernel(variant KernelVariant) (*Kernel, error) {
63	// All kernel variants are valid
64	if variant < KernelStable || variant > KernelCachyOS {
65		return nil, errors.New("invalid kernel variant")
66	}
67
68	return &Kernel{
69		variant: variant,
70	}, nil
71}
72
73// Variant returns the kernel variant
74func (k *Kernel) Variant() KernelVariant {
75	return k.variant
76}
77
78// PackageName returns the pacman package name
79func (k *Kernel) PackageName() string {
80	return k.variant.String()
81}
82
83// String returns human-readable representation
84func (k *Kernel) String() string {
85	return "Kernel(" + k.variant.String() + ")"
86}
87
88// Equals checks if two Kernel objects are equal
89func (k *Kernel) Equals(other *Kernel) bool {
90	if other == nil {
91		return false
92	}
93	return k.variant == other.variant
94}
95
96// AvailableKernels returns all available kernel variants
97func AvailableKernels() []KernelVariant {
98	return []KernelVariant{
99		KernelStable,
100		KernelZen,
101		KernelLTS,
102		KernelHardened,
103		KernelCachyOS,
104	}
105}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close