From 27e0c22baefa41b7682b48ddb58a8bdfc40ec9d3 Mon Sep 17 00:00:00 2001 From: Frost-Phoenix <67cyril6767@gmail.com> Date: Mon, 13 Nov 2023 00:16:48 +0100 Subject: [PATCH] change scripts --- modules/home/scripts/default.nix | 81 +++---------------- modules/home/scripts/scripts/commit copy.sh | 10 +++ modules/home/scripts/scripts/commit.sh | 10 +++ modules/home/scripts/scripts/dsize.sh | 7 ++ modules/home/scripts/scripts/music.sh | 12 +++ modules/home/scripts/scripts/push.sh | 11 +++ modules/home/scripts/scripts/runbg.sh | 16 ++++ .../home/scripts/{ => scripts}/toogle_blur.sh | 0 .../scripts/{ => scripts}/toogle_oppacity.sh | 0 .../home/scripts/scripts/wallpaper-picker.sh | 11 +++ 10 files changed, 86 insertions(+), 72 deletions(-) create mode 100644 modules/home/scripts/scripts/commit copy.sh create mode 100644 modules/home/scripts/scripts/commit.sh create mode 100644 modules/home/scripts/scripts/dsize.sh create mode 100644 modules/home/scripts/scripts/music.sh create mode 100644 modules/home/scripts/scripts/push.sh create mode 100644 modules/home/scripts/scripts/runbg.sh rename modules/home/scripts/{ => scripts}/toogle_blur.sh (100%) rename modules/home/scripts/{ => scripts}/toogle_oppacity.sh (100%) create mode 100644 modules/home/scripts/scripts/wallpaper-picker.sh diff --git a/modules/home/scripts/default.nix b/modules/home/scripts/default.nix index 0075101..c5e7b77 100644 --- a/modules/home/scripts/default.nix +++ b/modules/home/scripts/default.nix @@ -1,76 +1,13 @@ {pkgs, ...}: let - wall-change = pkgs.writeShellScriptBin "wall-change" '' - swaybg -m fill -i $1 - ''; - wallpaper-picker = pkgs.writeShellScriptBin "wallpaper-picker" '' - wallpaper_folder=$HOME/Pictures/wallpapers - wallpaper_location="$(ls $wallpaper_folder | wofi -n --show dmenu)" - if [[ -d $wallpaper_folder/$wallpaper_location ]]; then - wallpaper_temp="$wallpaper_location" - elif [[ -f $wallpaper_folder/$wallpaper_location ]]; then - wall-change $wallpaper_folder/$wallpaper_temp/$wallpaper_location - else - exit 1 - fi - ''; - push = pkgs.writeShellScriptBin "push" '' - git_directory=$PWD/.git - if [[ -d $git_directory ]];then - git add . - read -p "Enter commit name: " commit_name - git commit -m "$commit_name" - git push - else - echo "Git wasn't initialized here." - fi - ''; - commit = pkgs.writeShellScriptBin "commit" '' - git_directory=$PWD/.git - if [[ -d $git_directory ]];then - git add . - read -p "Enter commit name: " commit_name - git commit -m "$commit_name" - else - echo "Git wasn't initialized here." - fi - ''; - dsize = pkgs.writeShellScriptBin "dsize" '' - if [ "$#" -eq 1 ]; then - du -hs $1 - else - echo "[ERROR] => Wrong number of parameters" - fi - ''; - runbg = pkgs.writeShellScriptBin "runbg" '' - [ $# -eq 0 ] && { # $# is number of args - echo "$(basename $0): missing command" >&2 - exit 1 - } - prog="$(which "$1")" # see below - [ -z "$prog" ] && { - echo "$(basename $0): unknown command: $1" >&2 - exit 1 - } - shift # remove $1, now $prog, from args - tty -s && exec /dev/null # if stdout is a terminal, redirect to null - tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null) - "$prog" "$@" & # $@ is all args - ''; - music = pkgs.writeShellScriptBin "music" '' - if [[ $# == 0 ]]; then - hyprctl dispatch exec "[workspace 8 silent] audacious -t" - sleep 0.5 - audtool playlist-repeat-status |grep "on" || audtool playlist-repeat-toggle - audtool playlist-shuffle-status|grep "on" || audtool playlist-shuffle-toggle - elif [[ $1 == -s ]]; then - pkill audacious - else - echo "[ERROR] => Wrong argument..." - fi - ''; - toogle_blur = pkgs.writeScriptBin "toogle_blur" (builtins.readFile ./toogle_blur.sh); - toogle_oppacity = pkgs.writeScriptBin "toogle_oppacity" (builtins.readFile ./toogle_oppacity.sh); + wall-change = pkgs.writeShellScriptBin "wall-change" ''swaybg -m fill -i $1''; + wallpaper-picker = pkgs.writeShellScriptBin "wallpaper-picker" (builtins.readFile ./scripts/wallpaper-picker.sh); + push = pkgs.writeShellScriptBin "push" (builtins.readFile ./scripts/push.sh); + commit = pkgs.writeShellScriptBin "commit" (builtins.readFile ./scripts/commit.sh); + dsize = pkgs.writeShellScriptBin "dsize" (builtins.readFile ./scripts/dsize.sh); + runbg = pkgs.writeShellScriptBin "runbg" (builtins.readFile ./scripts/runbg.sh); + music = pkgs.writeShellScriptBin "music" (builtins.readFile ./scripts/music.sh); + toogle_blur = pkgs.writeScriptBin "toogle_blur" (builtins.readFile ./scripts/toogle_blur.sh); + toogle_oppacity = pkgs.writeScriptBin "toogle_oppacity" (builtins.readFile ./scripts/toogle_oppacity.sh); in { home.packages = with pkgs; [ wall-change diff --git a/modules/home/scripts/scripts/commit copy.sh b/modules/home/scripts/scripts/commit copy.sh new file mode 100644 index 0000000..79fd33f --- /dev/null +++ b/modules/home/scripts/scripts/commit copy.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +git_directory=$PWD/.git +if [[ -d $git_directory ]];then + git add . + read -p "Enter commit name: " commit_name + git commit -m "$commit_name" +else + echo "Git wasn't initialized here." +fi \ No newline at end of file diff --git a/modules/home/scripts/scripts/commit.sh b/modules/home/scripts/scripts/commit.sh new file mode 100644 index 0000000..79fd33f --- /dev/null +++ b/modules/home/scripts/scripts/commit.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +git_directory=$PWD/.git +if [[ -d $git_directory ]];then + git add . + read -p "Enter commit name: " commit_name + git commit -m "$commit_name" +else + echo "Git wasn't initialized here." +fi \ No newline at end of file diff --git a/modules/home/scripts/scripts/dsize.sh b/modules/home/scripts/scripts/dsize.sh new file mode 100644 index 0000000..47e52ec --- /dev/null +++ b/modules/home/scripts/scripts/dsize.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +if [ "$#" -eq 1 ]; then + du -hs $1 +else + echo "[ERROR] => Wrong number of parameters" +fi \ No newline at end of file diff --git a/modules/home/scripts/scripts/music.sh b/modules/home/scripts/scripts/music.sh new file mode 100644 index 0000000..e812055 --- /dev/null +++ b/modules/home/scripts/scripts/music.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +if [[ $# == 0 ]]; then + hyprctl dispatch exec "[workspace 8 silent] audacious -t" + sleep 0.5 + audtool playlist-repeat-status |grep "on" || audtool playlist-repeat-toggle + audtool playlist-shuffle-status|grep "on" || audtool playlist-shuffle-toggle +elif [[ $1 == -s ]]; then + pkill audacious +else + echo "[ERROR] => Wrong argument..." +fi \ No newline at end of file diff --git a/modules/home/scripts/scripts/push.sh b/modules/home/scripts/scripts/push.sh new file mode 100644 index 0000000..1d3152a --- /dev/null +++ b/modules/home/scripts/scripts/push.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +git_directory=$PWD/.git +if [[ -d $git_directory ]];then + git add . + read -p "Enter commit name: " commit_name + git commit -m "$commit_name" + git push +else + echo "Git wasn't initialized here." +fi \ No newline at end of file diff --git a/modules/home/scripts/scripts/runbg.sh b/modules/home/scripts/scripts/runbg.sh new file mode 100644 index 0000000..dc5088d --- /dev/null +++ b/modules/home/scripts/scripts/runbg.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +[ $# -eq 0 ] && { # $# is number of args + echo "$(basename $0): missing command" >&2 + exit 1 +} +prog="$(which "$1")" # see below +[ -z "$prog" ] && { + echo "$(basename $0): unknown command: $1" >&2 + exit 1 +} +shift # remove $1, now $prog, from args +tty -s && exec /dev/null # if stdout is a terminal, redirect to null +tty -s <&2 && exec 2>&1 # stderr to stdout (which might not be null) +"$prog" "$@" & # $@ is all args \ No newline at end of file diff --git a/modules/home/scripts/toogle_blur.sh b/modules/home/scripts/scripts/toogle_blur.sh similarity index 100% rename from modules/home/scripts/toogle_blur.sh rename to modules/home/scripts/scripts/toogle_blur.sh diff --git a/modules/home/scripts/toogle_oppacity.sh b/modules/home/scripts/scripts/toogle_oppacity.sh similarity index 100% rename from modules/home/scripts/toogle_oppacity.sh rename to modules/home/scripts/scripts/toogle_oppacity.sh diff --git a/modules/home/scripts/scripts/wallpaper-picker.sh b/modules/home/scripts/scripts/wallpaper-picker.sh new file mode 100644 index 0000000..eba0fd4 --- /dev/null +++ b/modules/home/scripts/scripts/wallpaper-picker.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +wallpaper_folder=$HOME/Pictures/wallpapers +wallpaper_location="$(ls $wallpaper_folder | wofi -n --show dmenu)" +if [[ -d $wallpaper_folder/$wallpaper_location ]]; then + wallpaper_temp="$wallpaper_location" +elif [[ -f $wallpaper_folder/$wallpaper_location ]]; then + wall-change $wallpaper_folder/$wallpaper_temp/$wallpaper_location +else + exit 1 +fi \ No newline at end of file