···
1
1
_: {
2
2
imports = [
3
3
-
./klem.nix
4
3
./screenlock.nix
5
4
./fetchWallpaper.nix
6
5
./sync-containers3.nix
···
1
1
-
{
2
2
-
self,
3
3
-
config,
4
4
-
lib,
5
5
-
pkgs,
6
6
-
...
7
7
-
}:
8
8
-
with lib;
9
9
-
let
10
10
-
cfg = config.lass.klem;
11
11
-
slib = self.inputs.stockholm.lib;
12
12
-
in
13
13
-
{
14
14
-
options.lass.klem = mkOption {
15
15
-
default = { };
16
16
-
type = types.attrsOf (
17
17
-
types.submodule (
18
18
-
{ config, ... }:
19
19
-
{
20
20
-
options = {
21
21
-
target = mkOption {
22
22
-
default = ".*";
23
23
-
description = ''
24
24
-
regex of valid targets
25
25
-
can be shown with xclip -selection clipboard -t TARGETS
26
26
-
the first hit is taken as target argument
27
27
-
'';
28
28
-
type = types.str;
29
29
-
};
30
30
-
script = mkOption {
31
31
-
description = ''
32
32
-
file to run if entry is selected
33
33
-
'';
34
34
-
type = types.path;
35
35
-
};
36
36
-
label = mkOption {
37
37
-
default = config._module.args.name;
38
38
-
description = ''
39
39
-
label to show in dmenu for this script
40
40
-
'';
41
41
-
type = types.str;
42
42
-
};
43
43
-
};
44
44
-
}
45
45
-
)
46
46
-
);
47
47
-
};
48
48
-
config =
49
49
-
let
50
50
-
klem = pkgs.writers.writeDashBin "klem" ''
51
51
-
set -x
52
52
-
53
53
-
labels=""
54
54
-
# match filetype against patterns
55
55
-
${concatMapStringsSep "\n" (script: ''
56
56
-
${pkgs.xclip}/bin/xclip -selection clipboard -target TARGETS -out \
57
57
-
| ${pkgs.gnugrep}/bin/grep -q '${script.target}'
58
58
-
if [ $? -eq 0 ]; then
59
59
-
labels="$labels:${script.label}"
60
60
-
fi
61
61
-
'') (attrValues cfg)}
62
62
-
63
63
-
#remove empty line, feed into dmenu
64
64
-
script=$(echo "$labels" \
65
65
-
| ${pkgs.gnused}/bin/sed 's/^://;s/:/\n/g' \
66
66
-
| ${pkgs.dmenu}/bin/dmenu)
67
67
-
68
68
-
#run the chosen script
69
69
-
case $script in
70
70
-
${concatMapStringsSep "\n" (
71
71
-
script:
72
72
-
slib.indent ''
73
73
-
${script.label})
74
74
-
target=$(${pkgs.xclip}/bin/xclip -selection clipboard -target TARGETS -out \
75
75
-
| ${pkgs.gnugrep}/bin/grep '${script.target}' \
76
76
-
| ${pkgs.gnugrep}/bin/grep -v TARGETS \
77
77
-
| ${pkgs.coreutils}/bin/head -1)
78
78
-
${pkgs.xclip}/bin/xclip -selection clipboard -target "$target" -out \
79
79
-
| ${script.script} \
80
80
-
| ${pkgs.xclip}/bin/xclip -selection clipboard -in
81
81
-
;;
82
82
-
''
83
83
-
) (attrValues cfg)}
84
84
-
esac
85
85
-
'';
86
86
-
in
87
87
-
mkIf (cfg != { }) {
88
88
-
environment.systemPackages = [ klem ];
89
89
-
nixpkgs.overlays = [
90
90
-
(_self: _super: {
91
91
-
klem = klem;
92
92
-
})
93
93
-
];
94
94
-
};
95
95
-
}
···
91
91
zathura
92
92
flameshot
93
93
(pkgs.writers.writeDashBin "screenshot" ''
94
94
-
set -efu
95
95
-
96
96
-
${pkgs.flameshot}/bin/flameshot gui &&
97
97
-
${pkgs.klem}/bin/klem
94
94
+
${pkgs.flameshot}/bin/flameshot gui
98
95
'')
99
96
(pkgs.writers.writeDashBin "IM" ''
100
97
${pkgs.mosh}/bin/mosh green.r -- tmux new-session -A -s IM -- weechat
···
137
134
dmenu = pkgs.writers.writeDashBin "dmenu" ''
138
135
${stockholmPkgs.fzfmenu}/bin/fzfmenu "$@"
139
136
'';
140
140
-
};
141
141
-
142
142
-
lass.klem = {
143
143
-
kpaste.script = pkgs.writers.writeDash "kpaste-wrapper" ''
144
144
-
${stockholmPkgs.kpaste}/bin/kpaste \
145
145
-
| ${pkgs.coreutils}/bin/tail -1 \
146
146
-
| ${pkgs.coreutils}/bin/tr -d '\r\n'
147
147
-
'';
148
148
-
go = {
149
149
-
target = "STRING";
150
150
-
script = "${stockholmPkgs.goify}/bin/goify";
151
151
-
};
152
152
-
"go.lassul.us" = {
153
153
-
target = "STRING";
154
154
-
script = pkgs.writers.writeDash "go.lassul.us" ''
155
155
-
export GO_HOST='go.lassul.us'
156
156
-
${stockholmPkgs.goify}/bin/goify
157
157
-
'';
158
158
-
};
159
159
-
qrcode = {
160
160
-
target = "image";
161
161
-
script = pkgs.writers.writeDash "zbar" ''
162
162
-
${pkgs.zbar}/bin/zbarimg -q --raw -
163
163
-
'';
164
164
-
};
165
165
-
ocr = {
166
166
-
target = "image";
167
167
-
script = pkgs.writers.writeDash "gocr" ''
168
168
-
${pkgs.netpbm}/bin/pngtopnm - \
169
169
-
| ${pkgs.gocr}/bin/gocr -
170
170
-
'';
171
171
-
};
172
137
};
173
138
174
139
services.clipmenu.enable = true;
···
157
157
, ("M4-c", spawn "/run/current-system/sw/bin/emacsclient -c")
158
158
-- , ("M4-c", unGrab)
159
159
, ("M4-f", floatNext True)
160
160
-
, ("M4-b", spawn "/run/current-system/sw/bin/klem")
161
160
162
161
, ("M4-c", defaultCommands >>= runCommand)
163
162
, ("M4-v", withWorkspace autoXPConfig (windows . W.greedyView))