Skip to content

Commit f921d7d

Browse files
committed
feat: snapshot scripts
1 parent 06568f1 commit f921d7d

File tree

3 files changed

+65
-23
lines changed

3 files changed

+65
-23
lines changed

home/denrei/common/optional/desktops/hyprland/default.nix

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,49 @@ let
1212
mpv "$(wl-paste)"
1313
'';
1414

15+
grimblast = "${inputs.hyprland-contrib.packages.${pkgs.system}.grimblast}/bin/grimblast";
1516
playerctl = "${pkgs.playerctl}/bin/playerctl";
1617
brightnessctl = "${pkgs.brightnessctl}/bin/brightnessctl";
1718
pactl = "${pkgs.pulseaudio}/bin/pactl";
19+
notify-send = "${pkgs.libnotify}/bin/notify-send";
20+
21+
snapshot = pkgs.writeShellScriptBin "snapshot" ''
22+
outputDir="$HOME/Pictures/Screenshots/"
23+
outputFile="snapshot_$(date +%Y-%m-%d_%H-%M-%S).png"
24+
outputPath="$outputDir/$outputFile"
25+
mkdir -p "$outputDir"
26+
27+
mode=''${1:-area}
28+
29+
case "$mode" in
30+
active)
31+
command="${grimblast} copysave active $outputPath"
32+
;;
33+
output)
34+
command="${grimblast} copysave output $outputPath"
35+
;;
36+
area)
37+
command="${grimblast} copysave area $outputPath"
38+
;;
39+
*)
40+
echo "Invalid option: $mode"
41+
echo "Usage: $0 {active|output|area}"
42+
exit 1
43+
;;
44+
esac
45+
46+
47+
if eval "$command"; then
48+
recentFile=$(find "$outputDir" -name 'snapshot_*.png' -printf '%T+ %p\n' | sort -r | head -n 1 | cut -d' ' -f2-)
49+
${notify-send} "Grimblast" "Your snapshot has been saved." \
50+
-i video-x-generic \
51+
-a "Grimblast" \
52+
-t 7000 \
53+
-u normal \
54+
--action="scriptAction:-xdg-open $outputDir=Directory" \
55+
--action="scriptAction:-xdg-open $recentFile=View"
56+
fi
57+
'';
1858
in
1959
{
2060
xdg.desktopEntries."org.gnome.Settings" = {
@@ -26,6 +66,10 @@ in
2666
terminal = false;
2767
};
2868

69+
home.packages = [
70+
inputs.hyprland-contrib.packages.${pkgs.system}.grimblast # or any other package
71+
];
72+
2973
wayland.windowManager.hyprland = {
3074
enable = true;
3175
package = null;
@@ -171,7 +215,7 @@ in
171215
# ",XF86PowerOff, ${e} -r 'powermenu.shutdown()'"
172216
# "SUPER, bracketleft, ${e} -r 'recorder.start()'"
173217
# "SUPER, bracketright, ${e} -r 'recorder.stop()'"
174-
# ",Print, ${e} -r 'recorder.screenshot()'"
218+
",Print, exec, ${snapshot}/bin/snapshot"
175219
# "SHIFT,Print, ${e} -r 'recorder.screenshot(true)'"
176220
# "SUPER, V, ${e} -r 'launcher.open(\":ch \")'"
177221
"SUPER, V, exec, rofi -modi clipboard:${pkgs.cliphist}/bin/cliphist-rofi-img -show clipboard -show-icons"
@@ -185,7 +229,7 @@ in
185229
"SUPER, X, exec, zeditor"
186230
"SUPER, D, exec, vesktop"
187231
"SUPER, M, exec, spotify"
188-
"SUPER, E, exec, gtk-launch org.gnome.Nautilus"
232+
"SUPER, E, exec, nautilus"
189233
"SUPER, I, exec, gtk-launch org.gnome.Settings"
190234

191235
# youtube

home/denrei/common/optional/hyprpanel/default.nix

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# *.nix
21
{
32
inputs,
43
lib,
@@ -67,18 +66,16 @@ in
6766
"clock"
6867
"media"
6968
];
70-
right =
71-
[
72-
"ram"
73-
"volume"
74-
"network"
75-
"systray"
76-
"notifications"
77-
]
78-
++ (if (builtins.getEnv "PC" != "1") then [ "battery" ] else [ ])
79-
++ [
80-
"power"
81-
];
69+
right = [
70+
"ram"
71+
"volume"
72+
"network"
73+
"bluetooth"
74+
"systray"
75+
"notifications"
76+
"power"
77+
"battery"
78+
];
8279
};
8380
};
8481
};

home/denrei/common/optional/rofi/config.rasi

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ configuration {
77
display-filebrowser: " Files";
88
display-window: " Windows";
99
display-clipboard: "󰅇 Clipboard";
10+
display-calc: " Calc";
1011
drun-display-format: "{name}";
1112
window-format: "{w} · {c} · {t}";
1213
font: "Ubuntu Nerd Font Propo 12";
@@ -155,14 +156,14 @@ click-to-exit: true;
155156
/* me-select-entry: "MousePrimary";*/
156157
/* me-accept-entry: "MouseDPrimary";*/
157158
/* me-accept-custom: "Control+MouseDPrimary";*/
158-
timeout {
159-
action: "kb-cancel";
160-
delay: 0;
161-
}
162-
filebrowser {
163-
directories-first: true;
164-
sorting-method: "name";
165-
}
159+
// timeout {
160+
// action: "kb-cancel";
161+
// delay: 0;
162+
// }
163+
// filebrowser {
164+
// directories-first: true;
165+
// sorting-method: "name";
166+
// }
166167
}
167168

168169
@theme "/dev/null"

0 commit comments

Comments
 (0)