blob: 54c763a91e01b7b8ad6df9126fc96041bb93a808 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
{
config,
pkgs,
lib,
...
}: let
cfg = config.features.gui.desktops.niri.parts.selectors;
aes = config.aesthetics;
defaultTerminal = config.default-applications.terminal-emulator;
in {
options.features.gui.desktops.niri.parts.selectors.enable = lib.mkEnableOption "selectors";
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
# Rebuild Loops
(pkgs.writers.writeNuBin "os-rebuild-loop" ''
try {nh os switch} ; while true {let continue = input "Rebuild? [Y/n] "; if (($continue | str downcase) == "y" or $continue == "") {try {nh os switch}} else {break}}
'')
(pkgs.writers.writeNuBin "home-rebuild-loop" ''
try {nh home switch} ; while true {let continue = input "Rebuild? [Y/n] "; if (($continue | str downcase) == "y" or $continue == "") {try {nh home switch}} else {break}}
'')
# Monitor Mirror Picker
(pkgs.writers.writeNuBin "mirror-display" ''
${pkgs.wl-mirror}/bin/wl-mirror (niri msg -j focused-output | from json | get name)
'')
# Tool Selector
(
pkgs.writers.writeNuBin "tool-selector"
/*
nu
*/
''
# Tools
let tools = {
"Rebuild NixOS": {
# footclient -H sudo nixos-rebuild switch --flake ($"~/Sync/setup#(hostname)" | path expand)
${defaultTerminal.runCliCommand} os-rebuild-loop
}
"Rebuild Home": {
# foot -H home-manager switch --flake ($"~/Sync/setup#(whoami)@(hostname)" | path expand)
${defaultTerminal.runCliCommand} home-rebuild-loop
}
"Update Flake": {
${defaultTerminal.runCliCommand} nix flake update --flake ($"~/Sync/setup/" | path expand)
}
"Manage WiFi": {
${defaultTerminal.runTuiCommand} ${pkgs.impala}/bin/impala
}
"Manage Bluetooth": {
${defaultTerminal.runTuiCommand} ${lib.getExe pkgs.bluetui}
}
"Manage Displays": {
${lib.getExe wdisplays}
}
"Mirror Current Display": {
mirror-display
}
"Reset Waybar": {
# Find a way to make this automatic when monitor connected and remove this
pkill waybar; niri msg action spawn -- waybar
}
"Create QR-Code": {
let temp_file = mktemp -t
let qr_code_bin = ${lib.getExe pkgs.qrtool} encode (${pkgs.wl-clipboard}/bin/wl-paste)
$qr_code_bin | ${pkgs.wl-clipboard}/bin/wl-copy
$qr_code_bin | save -f $temp_file
${lib.getExe pkgs.imv} $temp_file
}
# "Open Steam Big-Picture Mode": {
# rm -r ~/.steam
# gamescope -f --backend sdl -- steam -bigpicture
# }
"Switch to Secondary OS": {
# use sudo efibootmgr command to get identifiers
let identifier = match (hostname) {
"thinkpad-laptop" => "0001"
"nzxt-desktop" => "0000"
_ => "0000"
}
pkexec ${pkgs.efibootmgr}/bin/efibootmgr --bootnext $identifier ; reboot
}
"Review Inbox": {
${defaultTerminal.runCliCommand} ${pkgs.inbox-review}
}
}
# Logic
let user_tool_choice = $tools
| columns
| to text
| fuzzel -d --placeholder "Tools"
if ($user_tool_choice != "") {
do ($tools | get $user_tool_choice)
}
''
)
# Wallpaper Selector
(
writers.writeNuBin "wallpaper-selector"
/*
nu
*/
''
def main [
--all-outputs # Change wallpaper for all outputs
--randomize
] {
mut wallpapers = {}
for path in (ls ${aes.wallpapersDir}/**/* | where {|item| $item.type != dir} | get name) {
$wallpapers = $wallpapers | insert ($path | path basename | split row "." | get 0) $path
}
mut prompt = "Wallpaper (current)"
if $all_outputs {
$prompt = "Wallpaper (all)"
}
mut wallpaper_path = ""
if $randomize {
$wallpaper_path = $wallpapers | get (
$wallpapers
| columns
| shuffle
| get 0
)
} else {
$wallpaper_path = $wallpapers | get (
$wallpapers
| columns
| to text
| ${lib.getExe pkgs.fuzzel} -d --placeholder $prompt
)
}
if $all_outputs {
${lib.getExe pkgs.swww} img $wallpaper_path -t wipe --transition-fps 60 --transition-angle 45
} else {
let focused_display = niri msg -j focused-output
| from json
| get name
${lib.getExe pkgs.swww} img $wallpaper_path -t wipe --transition-fps 60 --transition-angle 45 --outputs $focused_display
}
}
''
)
# Scuffed Clipboard Selector
(
writers.writeNuBin "clipboard-selector" ''
let raw_list = ${lib.getExe pkgs.cliphist} list
let processed_list = $raw_list | split row "\n"
let list = $processed_list | split column "\t"
let choice_list = $list | each {return ($in.column1 + " " + $in.column0) }
let user_choice = $choice_list | to text | ${lib.getExe pkgs.fuzzel} -d --placeholder "Clipboard"
let choice_index = $choice_list | enumerate | where item == $user_choice | get index | get 0
$processed_list | get $choice_index | ${lib.getExe pkgs.cliphist} decode | ${pkgs.wl-clipboard}/bin/wl-copy
''
)
];
};
}
|