Skip to content

Commit

Permalink
home-desktop: move script and wallpaper to _pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
ocfox committed Apr 25, 2023
1 parent e41b063 commit bb6b1ce
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 81 deletions.
23 changes: 23 additions & 0 deletions home-desktop/_pkgs/macshot.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ lib
, pkgs
}:
with pkgs;
pkgs.writeShellScriptBin "macshot" ''
file=/tmp/xxx.png
${lib.getExe sway-contrib.grimshot} --notify save area /tmp/src.png >> /dev/null 2>&1
${imagemagick}/bin/convert /tmp/src.png \
\( +clone -alpha extract \
-draw 'fill black polygon 0,0 0,8 8,0 fill white circle 8,8 8,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite /tmp/output.png
${imagemagick}/bin/convert /tmp/output.png -bordercolor none -border 20 \
\( +clone -background black -shadow 80x8+15+15 \) \
+swap -background transparent -layers merge +repage $file
${wl-clipboard}/bin/wl-copy -t image/png < $file
${libnotify}/bin/notify-send "macshot copied"
rm /tmp/src.png /tmp/output.png
''
21 changes: 21 additions & 0 deletions home-desktop/_pkgs/powermenu.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ lib
, pkgs
}:
pkgs.writeShellScriptBin "powermenu" ''
options="shutdown\nreboot\nsuspend"
selection="$(${pkgs.coreutils}/bin/echo -e $options | \
${lib.getExe pkgs.bemenu} -i -l 4 -c -W 0.3)"
case $selection in
shutdown) ${pkgs.systemd}/bin/systemctl poweroff
exit 0
;;
reboot) ${pkgs.systemd}/bin/systemctl reboot
exit 0
;;
suspend) ${pkgs.systemd}/bin/systemctl suspend
exit 0
;;
esac
''
12 changes: 12 additions & 0 deletions home-desktop/_pkgs/recorder-status.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs }:
pkgs.writeShellScriptBin "record-status" ''
pid=`${pkgs.procps}/bin/pgrep wf-recorder`
status=$?
if [ $status != 0 ]
then
echo '';
else
echo '';
fi;
''
14 changes: 14 additions & 0 deletions home-desktop/_pkgs/recorder-toggle.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ lib
, pkgs
}:
pkgs.writeShellScriptBin "screen-recorder-toggle" ''
pid=`${pkgs.procps}/bin/pgrep wf-recorder`
status=$?
if [ $status != 0 ]
then
${lib.getExe pkgs.wf-recorder} -g "$(${lib.getExe pkgs.slurp})" -f $HOME/Videos/record/$(date +'recording_%Y-%m-%d-%H%M%S.mp4');
else
${pkgs.procps}/bin/pkill --signal SIGINT wf-recorder
fi;
''
28 changes: 28 additions & 0 deletions home-desktop/_pkgs/wallpapers.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{ lib, pkgs }:
{
door = pkgs.fetchurl {
url = "https://pastb.in/door.jpg";
name = "door.jpg";
hash = "sha256-4Gf2IvehQ9JXD1kzgYRNFZZi17UWx++09tU05U7Q7To=";
};

cowboyBebop = {
op = pkgs.fetchurl {
url = "https://pastb.in/cowboybebop-op.jpg";
name = "cowboybebop-op.jpg";
hash = "sha256-Re6bEdMwQae+E2JNq/5Ah+9iuaJIgFHxg8UqJ36itA8=";
};

sky = pkgs.fetchurl {
url = "https://pastb.in/cowboybebop-sky.jpg";
name = "cowboybebop-sky.jpg";
hash = "sha256-2fhkMXkNCvkmuA7yTOzTa/3AQxgu2QsSKGqHAxOB7K4=";
};

bebop = pkgs.fetchurl {
url = "https://pastb.in/cowboybebop-bebop.jpg";
name = "cowboybebop-bebop.jpg";
hash = "sha256-nWw1gnXq526ykBl31or5DBYUVDmEshqs5Jz2mQlKSMQ=";
};
};
}
71 changes: 0 additions & 71 deletions home-desktop/home/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,75 +24,4 @@ with pkgs;
nur.repos.xddxdd.qq

texlive.combined.scheme-medium
(
pkgs.writeShellScriptBin "record-status" ''
#!/usr/bin/env bash
pid=`pgrep wf-recorder`
status=$?
if [ $status != 0 ]
then
echo '';
else
echo '';
fi;
''
)

(
pkgs.writeShellScriptBin "screen-recorder-toggle" ''
#!/usr/bin/env bash
pid=`${pkgs.procps}/bin/pgrep wf-recorder`
status=$?
if [ $status != 0 ]
then
${lib.getExe pkgs.wf-recorder} -g "$(${lib.getExe pkgs.slurp})" -f $HOME/Videos/record/$(date +'recording_%Y-%m-%d-%H%M%S.mp4');
else
${pkgs.procps}/bin/pkill --signal SIGINT wf-recorder
fi;
''
)

(
pkgs.writeShellScriptBin "power-menu" ''
#!/usr/bin/env bash
options="shutdown\nreboot\nsuspend\nexit sway"
selection="$(${pkgs.coreutils}/bin/echo -e $options | \
${lib.getExe pkgs.bemenu} -i -l 4 -c -W 0.3)"
case $selection in
shutdown) ${pkgs.systemd}/bin/systemctl poweroff
exit 0
;;
reboot) ${pkgs.systemd}/bin/systemctl reboot
exit 0
;;
suspend) ${pkgs.systemd}/bin/systemctl suspend
exit 0
;;
esac''
)
(
writeShellScriptBin "mac-shot" ''
file=/tmp/xxx.png
${lib.getExe sway-contrib.grimshot} --notify save area /tmp/src.png >> /dev/null 2>&1
${imagemagick}/bin/convert /tmp/src.png \
\( +clone -alpha extract \
-draw 'fill black polygon 0,0 0,8 8,0 fill white circle 8,8 8,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite /tmp/output.png
${imagemagick}/bin/convert /tmp/output.png -bordercolor none -border 20 \
\( +clone -background black -shadow 80x8+15+15 \) \
+swap -background transparent -layers merge +repage $file
${wl-clipboard}/bin/wl-copy -t image/png < $file
${libnotify}/bin/notify-send "macshot copied"
rm /tmp/src.png /tmp/output.png
''
)
]
26 changes: 17 additions & 9 deletions home-desktop/wayland/windowManager/sway.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ config
, lib
, root
, pkgs
}: {
enable = true;
Expand All @@ -22,14 +24,18 @@
"5" = [{ app_id = "thunderbird"; }];
};

output = {
DP-1 = {
bg = "~/Pictures/Wallpapers/rurudo.jpg fill";
mode = "3840x2160";
position = "0 0";
scale = "3";
output =
let
inherit (root.pkgs) wallpapers;
in
{
DP-1 = {
bg = "${wallpapers.door} fill";
mode = "3840x2160";
position = "0 0";
scale = "3";
};
};
};

window = {
titlebar = false;
Expand All @@ -39,6 +45,7 @@
keybindings =
let
modifier = config.wayland.windowManager.sway.config.modifier;
inherit (root.pkgs) macshot powermenu recorder-toggle;
in
pkgs.lib.mkOptionDefault {
"${modifier}+h" = "focus left";
Expand All @@ -47,15 +54,16 @@
"${modifier}+l" = "focus right";
"${modifier}+d" = "move scratchpad";
"${modifier}+i" = "scratchpad show";
"${modifier}+Shift+a" = "exec ${lib.getExe macshot}";
"${modifier}+Shift+u" = "exec pamixer -i 10";
"${modifier}+Shift+d" = "exec pamixer -d 10";
"${modifier}+Shift+e" = "exec power-menu";
"${modifier}+Shift+e" = "exec ${lib.getExe powermenu}";
"${modifier}+Return" = "exec ${pkgs.kitty}/bin/kitty";
"${modifier}+o" = "exec ${pkgs.bemenu}/bin/bemenu-run -c -l 15 -W 0.3";
"${modifier}+space" = "floating toggle";
"${modifier}+Shift+space" = null;
"${modifier}+Shift+s" = "exec ${pkgs.sway-contrib.grimshot}/bin/grimshot copy area";
"${modifier}+Shift+r" = "exec screen-recorder-toggle";
"${modifier}+Shift+r" = "exec ${lib.getExe recorder-toggle}";
};
colors = {
focused = {
Expand Down
2 changes: 1 addition & 1 deletion hosts/whitefox/boot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
grub2-theme = {
enable = true;
theme = "whitesur";
screen = "2k";
screen = "4k";
};
grub = {
enable = true;
Expand Down

0 comments on commit bb6b1ce

Please sign in to comment.