cleanup scripts
This commit is contained in:
parent
5e0bfd0aa4
commit
5c5c3a4027
14 changed files with 153 additions and 61 deletions
|
@ -83,10 +83,10 @@
|
|||
inherit system;
|
||||
};
|
||||
in
|
||||
with pkgs; {
|
||||
formatter = nixpkgs-fmt;
|
||||
devShells.default = mkShell {
|
||||
buildInputs = [
|
||||
{
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [
|
||||
git
|
||||
git-crypt
|
||||
statix
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
{ config, pkgs, ... }:
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
pictures = "${config.xdg.userDirs.pictures}";
|
||||
change-wallpaper = "${pkgs.scripts}/bin/chpaper ${pictures}/Wallpapers";
|
||||
wallpaper-downloader = "${pkgs.scripts}/bin/wallhaven ${pictures}/Wallpapers";
|
||||
change-wallpaper = "${pkgs.setpaper}/bin/setpaper";
|
||||
wallpaper-downloader = "${pkgs.getpaper}/bin/getpaper";
|
||||
in
|
||||
{
|
||||
systemd.user = {
|
||||
|
|
|
@ -167,9 +167,9 @@ in
|
|||
"SUPER,i, exec, ${firefox}"
|
||||
"SUPER_SHIFT,i, exec, ${firefox} --private-window"
|
||||
|
||||
"SUPER_SHIFT,escape, exec, ${pkgs.scripts}/bin/power-menu"
|
||||
"SUPER,f11, exec, ${pkgs.scripts}/bin/tmux-sessions"
|
||||
"SUPER_SHIFT,y, exec, ${pkgs.scripts}/bin/youtube"
|
||||
"SUPER_SHIFT,escape, exec, ${pkgs.misc-scripts}/bin/power-menu"
|
||||
"SUPER,f11, exec, ${pkgs.misc-scripts}/bin/tmux-sessions"
|
||||
"SUPER_SHIFT,y, exec, ${pkgs.youtube}/bin/youtube"
|
||||
"SUPER_SHIFT,b, exec, ${pkgs.rofi-bluetooth}/bin/rofi-bluetooth"
|
||||
|
||||
"SUPER,escape, exec, ${loginctl} lock-session"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
final: prev: {
|
||||
dracula-gtk = prev.callPackage ./dracula-gtk { };
|
||||
scripts = prev.callPackage ./scripts { };
|
||||
misc-scripts = prev.callPackage ./scripts/misc { };
|
||||
getpaper = prev.callPackage ./scripts/getpaper { };
|
||||
setpaper = prev.callPackage ./scripts/setpaper { };
|
||||
youtube = prev.callPackage ./scripts/youtube { };
|
||||
rofi-bluetooth = prev.callPackage ./rofi-bluetooth { };
|
||||
smc-manjari = prev.callPackage ./smc-manjari { };
|
||||
smc-nupuram = prev.callPackage ./smc-nupuram { };
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
DIR="${1:-}"
|
||||
if [ -z "$DIR" ]; then
|
||||
echo "Usage: $0 <path to directory containing wallpapers>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
random_paper() {
|
||||
if [ -d "$DIR" ] ; then
|
||||
find -L "${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1 --random-source=/dev/urandom
|
||||
elif [ -f "$DIR" ] ; then
|
||||
echo "$DIR"
|
||||
fi
|
||||
}
|
||||
|
||||
swww img \
|
||||
--transition-type any \
|
||||
--transition-step 2 \
|
||||
--transition-duration 2 \
|
||||
"$(random_paper)"
|
||||
|
30
packages/scripts/getpaper/default.nix
Normal file
30
packages/scripts/getpaper/default.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{ lib
|
||||
, stdenvNoCC
|
||||
, makeWrapper
|
||||
, curl
|
||||
, envsubst
|
||||
, jq
|
||||
, libsecret
|
||||
,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "getpaper";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cp getpaper.sh $out/bin/getpaper
|
||||
chmod +x $out/bin/getpaper
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/getpaper --prefix PATH : ${lib.makeBinPath [envsubst jq curl libsecret]}
|
||||
'';
|
||||
}
|
|
@ -11,17 +11,23 @@ fi
|
|||
|
||||
CURL_BASE_CMD="curl --silent ${API_KEY_HEADER}"
|
||||
|
||||
DIR="${1:-/tmp}"
|
||||
mkdir -p "${DIR}"
|
||||
|
||||
CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}"
|
||||
CONFIG_FILE="${CONFIG_DIR}/wallpaper_config.json"
|
||||
if [ ! -e "${CONFIG_FILE}" ]; then
|
||||
echo '{"tags":null,"categories":"100","purity":"100", "sorting":"random", "size":null, "ratios":null, "colors":null, "ai_filter":1, "range": "1M"}' | jq > "${CONFIG_FILE}"
|
||||
echo '{"tags":null,"categories":"100","purity":"100", "sorting":"random", "size":null, "ratios":null, "colors":null, "ai_filter":1, "range": "1M", "dir":"~/Pictures/Wallpapers"}' | jq > "${CONFIG_FILE}"
|
||||
fi
|
||||
|
||||
CONFIG="$(cat "${CONFIG_FILE}")"
|
||||
|
||||
DIR="$(echo "${CONFIG}" | jq -r '.dir // empty')"
|
||||
if [ -z "${DIR}" ]; then
|
||||
DIR="${XDG_PICTURES_DIR:-${HOME}/Pictures}/Wallpapers"
|
||||
echo "Warning: wallpaper directory not set. using fallback directory ${DIR}" >&2
|
||||
fi
|
||||
|
||||
DIR="$(echo "${DIR}" | envsubst)"
|
||||
mkdir -p "${DIR}"
|
||||
|
||||
AI_FILTER="$(echo "${CONFIG}" | jq -r '.ai_filter // empty')"
|
||||
if [ -n "${AI_FILTER}" ]; then
|
||||
AI_FILTER="ai_art_filter=${AI_FILTER}&"
|
||||
|
@ -38,7 +44,7 @@ if [ -n "${CATEGORIES}" ]; then
|
|||
fi
|
||||
|
||||
PURITY="$(echo "${CONFIG}" | jq -r '.purity // empty')"
|
||||
if [ -n "${PURITY}" ]; then
|
||||
if [ -n "${PURITY}" ] && [ -n "${API_KEY_HEADER}" ]; then
|
||||
PURITY="purity=${PURITY}&"
|
||||
fi
|
||||
|
|
@ -1,22 +1,16 @@
|
|||
{ lib
|
||||
, stdenvNoCC
|
||||
, makeWrapper
|
||||
, curl
|
||||
, hyprland
|
||||
, jq
|
||||
, kitty
|
||||
, libnotify
|
||||
, libsecret
|
||||
, rofi-wayland
|
||||
, swww
|
||||
, tmux
|
||||
, ueberzugpp
|
||||
, ytfzf
|
||||
,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "scripts";
|
||||
version = "1.0";
|
||||
pname = "misc-scripts";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
@ -32,23 +26,11 @@ stdenvNoCC.mkDerivation {
|
|||
cp tmux-sessions.sh $out/bin/tmux-sessions
|
||||
chmod +x $out/bin/tmux-sessions
|
||||
|
||||
cp chpaper.sh $out/bin/chpaper
|
||||
chmod +x $out/bin/chpaper
|
||||
|
||||
cp wallhaven.sh $out/bin/wallhaven
|
||||
chmod +x $out/bin/wallhaven
|
||||
|
||||
cp youtube.sh $out/bin/youtube
|
||||
chmod +x $out/bin/youtube
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/power-menu --prefix PATH : ${lib.makeBinPath [libnotify rofi-wayland hyprland]}
|
||||
wrapProgram $out/bin/tmux-sessions --prefix PATH : ${lib.makeBinPath [tmux kitty rofi-wayland]}
|
||||
wrapProgram $out/bin/chpaper --prefix PATH : ${lib.makeBinPath [swww]}
|
||||
wrapProgram $out/bin/wallhaven --prefix PATH : ${lib.makeBinPath [jq curl libsecret]}
|
||||
wrapProgram $out/bin/youtube --prefix PATH : ${lib.makeBinPath [kitty ytfzf rofi-wayland ueberzugpp]}
|
||||
'';
|
||||
}
|
29
packages/scripts/setpaper/default.nix
Normal file
29
packages/scripts/setpaper/default.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{ lib
|
||||
, stdenvNoCC
|
||||
, makeWrapper
|
||||
, envsubst
|
||||
, jq
|
||||
, swww
|
||||
,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "setpaper";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
cp setpaper.sh $out/bin/setpaper
|
||||
chmod +x $out/bin/setpaper
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/setpaper --prefix PATH : ${lib.makeBinPath [envsubst jq swww]}
|
||||
'';
|
||||
}
|
36
packages/scripts/setpaper/setpaper.sh
Executable file
36
packages/scripts/setpaper/setpaper.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}"
|
||||
CONFIG_FILE="${CONFIG_DIR}/wallpaper_config.json"
|
||||
if [ ! -e "${CONFIG_FILE}" ]; then
|
||||
echo "Wallpaper config file: ${CONFIG_FILE} missing." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CONFIG="$(cat "${CONFIG_FILE}")"
|
||||
|
||||
DIR="$(echo "${CONFIG}" | jq -r '.dir // empty')"
|
||||
if [ -z "${DIR}" ]; then
|
||||
DIR="${XDG_PICTURES_DIR:-${HOME}/Pictures}/Wallpapers"
|
||||
echo "Warning: wallpaper directory not set. using fallback directory ${DIR}" >&2
|
||||
fi
|
||||
DIR="$(echo "${DIR}" | envsubst)"
|
||||
mkdir -p "${DIR}"
|
||||
|
||||
random_paper() {
|
||||
if [ -d "$DIR" ] ; then
|
||||
find -L "${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1 --random-source=/dev/urandom
|
||||
else
|
||||
echo "${DIR} is not a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
swww img \
|
||||
--transition-type any \
|
||||
--transition-step 2 \
|
||||
--transition-duration 2 \
|
||||
"$(random_paper)"
|
||||
|
31
packages/scripts/youtube/default.nix
Normal file
31
packages/scripts/youtube/default.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ lib
|
||||
, stdenvNoCC
|
||||
, makeWrapper
|
||||
, kitty
|
||||
, rofi-wayland
|
||||
, ueberzugpp
|
||||
, ytfzf
|
||||
,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "youtube";
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
|
||||
cp youtube.sh $out/bin/youtube
|
||||
chmod +x $out/bin/youtube
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/youtube --prefix PATH : ${lib.makeBinPath [kitty ytfzf rofi-wayland ueberzugpp]}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue