Modularize scripts
This commit is contained in:
parent
96b410a358
commit
225da437c5
30 changed files with 590 additions and 423 deletions
|
|
@ -17,12 +17,15 @@
|
|||
./hyprland
|
||||
./kde_connect.nix
|
||||
./keepassxc.nix
|
||||
./kitty.nix
|
||||
./layout.nix
|
||||
./media.nix
|
||||
./ncspot.nix
|
||||
./nextcloud.nix
|
||||
./oxi
|
||||
./piper.nix
|
||||
./printing.nix
|
||||
./scripts.nix
|
||||
./sops.nix
|
||||
./starship.nix
|
||||
./stylix.nix
|
||||
|
|
@ -30,6 +33,5 @@
|
|||
./virtualbox.nix
|
||||
./xone.nix
|
||||
./yazi
|
||||
./kitty.nix
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,12 +69,8 @@
|
|||
|
||||
#my own programs
|
||||
programs = {
|
||||
oxicalc.enable = true;
|
||||
oxinoti.enable = true;
|
||||
oxidash.enable = true;
|
||||
oxishut.enable = true;
|
||||
oxipaste.enable = true;
|
||||
hyprdock.enable = true;
|
||||
oxicalc.enable = true;
|
||||
ReSet.enable = true;
|
||||
ReSet.config.plugins = [
|
||||
inputs.reset-plugins.packages."x86_64-linux".monitor
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
{ config, lib, options, pkgs, ... }: {
|
||||
imports = [
|
||||
|
||||
];
|
||||
|
||||
options.mods = {
|
||||
hyprland = {
|
||||
enable = lib.mkOption {
|
||||
|
|
@ -92,11 +88,9 @@
|
|||
bind = [
|
||||
# screenshots
|
||||
''$mod SUPER,S,exec,grim -g "$(slurp)" - | wl-copy''
|
||||
''
|
||||
$mod SUPERSHIFTALT,S,exec, grim -g "$(slurp)" $HOME/gits/ost-5semester/Screenshots/$(date +'%Y_%m_%d_%I_%M_%S.png') && (date +'%Y_%m_%d_%I_%M_%S.png') | wl-copy''
|
||||
''$mod SUPERSHIFT,S,exec,grim -g "$(slurp)" - | satty -f -''
|
||||
''
|
||||
$mod SUPERCONTROLSHIFT,S,exec,grim -c -g "2560,0 3440x1440" - | wl-copy''
|
||||
$mod SUPERSHIFTALT,S,exec,grim -c -g "2560,0 3440x1440" - | wl-copy''
|
||||
|
||||
# regular programs
|
||||
"$mod SUPER,F,exec,firefox"
|
||||
|
|
@ -114,14 +108,19 @@
|
|||
"$mod SUPERSHIFT,K,exec, playerctl -a pause & hyprlock & systemctl hibernate"
|
||||
|
||||
# media keys
|
||||
",XF86AudioMute,exec, $HOME/.config/scripts/audio_control.sh mute"
|
||||
",XF86AudioLowerVolume,exec, $HOME/.config/scripts/audio_control.sh sink -5%"
|
||||
",XF86AudioRaiseVolume,exec, $HOME/.config/scripts/audio_control.sh sink +5%"
|
||||
(lib.mkIf config.mods.scripts.audio-control
|
||||
",XF86AudioMute,exec, audio-control mute")
|
||||
(lib.mkIf config.mods.scripts.audio-control
|
||||
",XF86AudioLowerVolume,exec, audio-control sink -5%")
|
||||
(lib.mkIf config.mods.scripts.audio-control
|
||||
",XF86AudioRaiseVolume,exec, audio-control sink +5%")
|
||||
",XF86AudioPlay,exec, playerctl play-pause"
|
||||
",XF86AudioNext,exec, playerctl next"
|
||||
",XF86AudioPrev,exec, playerctl previous"
|
||||
",XF86MonBrightnessDown,exec, $HOME/.config/scripts/change-brightness brightness 10%-"
|
||||
",XF86MonBrightnessUp,exec, $HOME/.config/scripts/change-brightness brightness +10%"
|
||||
(lib.mkIf config.mods.scripts.change-brightness
|
||||
",XF86MonBrightnessDown,exec, change-brightness brightness 10%-")
|
||||
(lib.mkIf config.mods.scripts.change-brightness
|
||||
",XF86MonBrightnessUp,exec, change-brightness brightness +10%")
|
||||
|
||||
# hyprland keybinds
|
||||
# misc
|
||||
|
|
|
|||
57
modules/programs/oxi/default.nix
Normal file
57
modules/programs/oxi/default.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{ lib, config, options, inputs, ... }: {
|
||||
imports = [ ./oxidash.nix ./oxinoti.nix ./oxishut.nix ./oxipaste.nix ];
|
||||
options.mods.oxi = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables oxi programs";
|
||||
};
|
||||
ReSet = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables and configures ReSet";
|
||||
};
|
||||
};
|
||||
hyprdock = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables hyprdock";
|
||||
};
|
||||
};
|
||||
oxicalc = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables hyprdock";
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf config.mods.oxi.enable
|
||||
(lib.optionalAttrs (options ? home.packages) {
|
||||
programs = {
|
||||
hyprdock.enable = lib.mkIf config.mods.oxi.hyprdock.enable true;
|
||||
oxicalc.enable = lib.mkIf config.mods.oxi.oxicalc.enable true;
|
||||
ReSet = lib.mkIf config.mods.oxi.ReSet.enable {
|
||||
enable = true;
|
||||
config = {
|
||||
plugins = [
|
||||
inputs.reset-plugins.packages."x86_64-linux".monitor
|
||||
inputs.reset-plugins.packages."x86_64-linux".keyboard
|
||||
];
|
||||
plugin_config = {
|
||||
Keyboard = {
|
||||
path =
|
||||
"/home/${config.conf.username}/.config/reset/keyboard.conf";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
64
modules/programs/oxi/oxidash.nix
Normal file
64
modules/programs/oxi/oxidash.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{ lib, config, options, ... }: {
|
||||
options.mods.oxi.oxidash = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables and configures oxidash";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (config.mods.oxi.oxidash.enable && config.mods.oxi.enable)
|
||||
(lib.optionalAttrs (options ? xdg.configFile) {
|
||||
programs.oxidash.enable = true;
|
||||
xdg.configFile."oxidash/style.css" = {
|
||||
text = ''
|
||||
#MainWindow {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#MainBox {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
#MainButtonBox {
|
||||
padding: 10px;
|
||||
margin: 5px 0px 5px 0px;
|
||||
border-radius: 5px;
|
||||
border: solid 2px #327cd5;
|
||||
}
|
||||
|
||||
#DoNotDisturbButton {
|
||||
}
|
||||
|
||||
#ExitButton {
|
||||
}
|
||||
|
||||
#ClearNotificationsButton {
|
||||
}
|
||||
|
||||
#NotificationsWindow {
|
||||
}
|
||||
|
||||
.debugimage {
|
||||
border: solid 3px blue;
|
||||
}
|
||||
|
||||
.Notification {
|
||||
padding: 10px;
|
||||
margin: 5px 0px 5px 0px;
|
||||
border: solid 2px #327cd5;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.CloseNotificationButton {
|
||||
margin: 0px 5px 0px 10px;
|
||||
}
|
||||
.PictureButtonBox {
|
||||
}
|
||||
.BaseBox {
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
104
modules/programs/oxi/oxinoti.nix
Normal file
104
modules/programs/oxi/oxinoti.nix
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
{ lib, config, options, ... }: {
|
||||
options.mods.oxi.oxinoti = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables and configures oxinoti";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (config.mods.oxi.oxinoti.enable && config.mods.oxi.enable)
|
||||
(lib.optionalAttrs (options ? xdg.configFile) {
|
||||
programs.oxinoti.enable = true;
|
||||
xdg.configFile."oxinoti/style.css" = {
|
||||
text = # css
|
||||
''
|
||||
@import url("/home/${config.conf.username}/.config/gtk-3.0/gtk.css");
|
||||
|
||||
#MainWindow {
|
||||
background-color: transparent;
|
||||
padding: 0px;
|
||||
/* opacity: 0; */
|
||||
}
|
||||
|
||||
.MainBox {
|
||||
background-color: transparent;
|
||||
padding: 0px;
|
||||
/* opacity: 0; */
|
||||
}
|
||||
|
||||
.NotificationBox {
|
||||
background-color: #353747;
|
||||
border-radius: 5px;
|
||||
border: solid 1px;
|
||||
margin: 0px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.NotificationLow {
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.NotificationNormal {
|
||||
border-color: purple;
|
||||
}
|
||||
|
||||
.NotificationUrgent {
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.miscbox {
|
||||
margin: 0px 10px 0px 0px;
|
||||
}
|
||||
|
||||
.bodybox {
|
||||
}
|
||||
|
||||
.imagebox {
|
||||
margin: 0px 0px 0px 10px;
|
||||
}
|
||||
|
||||
.appname {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.summary {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.body {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.image {
|
||||
}
|
||||
|
||||
.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
'';
|
||||
};
|
||||
xdg.configFile."oxinoti/oxinoti.toml" = {
|
||||
text = ''
|
||||
timeout = 3
|
||||
dnd_override = 2
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
42
modules/programs/oxi/oxipaste.nix
Normal file
42
modules/programs/oxi/oxipaste.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{ lib, config, options, ... }: {
|
||||
options.mods.oxi.oxipaste = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables and configures oxipaste";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (config.mods.oxi.oxipaste.enable && config.mods.oxi.enable)
|
||||
(lib.optionalAttrs (options ? xdg.configFile) {
|
||||
programs.oxipaste.enable = true;
|
||||
xdg.configFile."oxipaste/style.css" = {
|
||||
text = ''
|
||||
.main-window {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 2px solid #2AC3DE;
|
||||
}
|
||||
|
||||
.item-window {
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
border: 2px solid #C0CAF5;
|
||||
}
|
||||
|
||||
.item-button {
|
||||
background-color: #1A1B26;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #6D728D;
|
||||
}
|
||||
|
||||
.delete-button {
|
||||
margin: 5px 25px 5px 5px;
|
||||
}
|
||||
|
||||
.item-box {
|
||||
}
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
36
modules/programs/oxi/oxishut.nix
Normal file
36
modules/programs/oxi/oxishut.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{ lib, config, options, ... }: {
|
||||
options.mods.oxi.oxishut = {
|
||||
enable = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables and configures oxishut";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf (config.mods.oxi.oxishut.enable && config.mods.oxi.enable)
|
||||
(lib.optionalAttrs (options ? xdg.configFile) {
|
||||
programs.oxishut.enable = true;
|
||||
xdg.configFile."oxishut/style.css" = {
|
||||
text = ''
|
||||
#mainwindow {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.mainbox {
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin: 5px;
|
||||
background-color: #2b2c3b;
|
||||
-gtk-icon-size: 5rem;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #3e4152;
|
||||
}
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
120
modules/programs/scripts.nix
Normal file
120
modules/programs/scripts.nix
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
{ lib, config, options, pkgs, ... }: {
|
||||
options.mods.scripts = {
|
||||
change-brightness = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables the change-brightness script";
|
||||
};
|
||||
audio-control = lib.mkOption {
|
||||
default = true;
|
||||
example = false;
|
||||
type = lib.types.bool;
|
||||
description = "Enables the audio-control script";
|
||||
};
|
||||
scripts = lib.mkOption {
|
||||
default = [ ];
|
||||
example = [ ];
|
||||
description =
|
||||
"More scripts to be passed. (check existing ones for types and examples)";
|
||||
};
|
||||
};
|
||||
config = (lib.optionalAttrs (options ? home.packages) {
|
||||
home.packages = [
|
||||
(lib.mkIf config.mods.scripts.change-brightness
|
||||
(pkgs.writeShellScriptBin "change-brightness" ''
|
||||
set_brightness() {
|
||||
brightnessctl set "$1"
|
||||
CURRENT=$(brightnessctl -m -d intel_backlight | awk -F, '{print substr($4, 0, length($4)-1)}')
|
||||
dunstify -a "changeBrightness" -r 3 -u low -i brightness-high -h int:value:"$CURRENT" "Brightness: $\{CURRENT\}%"
|
||||
}
|
||||
|
||||
if [ "$1" == "brightness" ]; then
|
||||
set_brightness "$2"
|
||||
fi
|
||||
''))
|
||||
(lib.mkIf config.mods.scripts.audio-control
|
||||
(pkgs.writeShellScriptBin "audio-control" ''
|
||||
ncspot() {
|
||||
NUM=$(pactl list clients short | rg "ncspot" | awk -F 'PipeWire' ' { print $1 } ' | tr -d ' \t\n')
|
||||
CHANGE=$(pactl list sink-inputs short | rg "$NUM" | awk -F ' ' ' { print $1 }' | tr -d ' \t\n')
|
||||
pactl set-sink-input-volume "$CHANGE" "$1"
|
||||
VOLUME=$(pactl list sink-inputs | rg "$NUM" -A7 | rg "Volume:" | awk -F ' ' ' { print $5 }' | tr -d '%')
|
||||
notify-send -a "ncspot" -r 990 -u low -i audio-volume-high -h int:progress:"$VOLUME" "Spotify Volume: $\{VOLUME\}%"
|
||||
}
|
||||
|
||||
firefox() {
|
||||
STRING=$(pactl list clients short | rg "firefox" | awk -F 'PipeWire' ' { print $1 "," } ' | tr -d ' \t\n')
|
||||
# NUMS=',' read -r -a array <<< "$STRING"
|
||||
readarray -td, NUMS <<<"$STRING"
|
||||
declare -p NUMS
|
||||
for index in "$\{!NUMS[@]\}"; do #"$\{!array[@]\}"
|
||||
NUM=$(echo "$\{NUMS[index]\}" | tr -d ' \t\n')
|
||||
CHANGE=$(pactl list sink-inputs short | rg "$NUM" | awk -F ' ' ' { print $1 }' | tr -d ' \t\n')
|
||||
pactl set-sink-input-volume "$CHANGE" "$1"
|
||||
done
|
||||
VOLUME=$(pactl list sink-inputs | rg "$\{NUMS[0]\}" -A7 | rg "Volume:" | awk -F ' ' ' { print $5 }' | tr -d '%')
|
||||
notify-send -a "Firefox" -r 991 -u low -i audio-volume-high -h int:progress:"$VOLUME" "Firefox Volume: $\{VOLUME\}%"
|
||||
}
|
||||
|
||||
internal() {
|
||||
SPEAKER=$(pactl list sinks | grep "Name" | grep "alsa" | awk -F ': ' '{ print $2 }')
|
||||
if [ "$SPEAKER" != "" ]; then
|
||||
pactl set-default-sink "$SPEAKER"
|
||||
pactl set-sink-mute "$SPEAKER" false
|
||||
DEVICE=$(echo "$SPEAKER" | awk -F '.' ' { print $4 } ')
|
||||
notify-send "changed audio to "$DEVICE" "
|
||||
else
|
||||
notify-send "failed, not available!"
|
||||
fi
|
||||
}
|
||||
|
||||
set_volume_sink() {
|
||||
pactl set-sink-volume @DEFAULT_SINK@ "$1"
|
||||
CURRENT=$(pactl get-sink-volume @DEFAULT_SINK@ | awk -F'/' '{ print $2 }' | tr -d ' %')
|
||||
notify-send -a "System Volume" -r 1001 -u low -i audio-volume-high -h int:progress:"$CURRENT" "Output Volume: $\{CURRENT\}%"
|
||||
}
|
||||
|
||||
set_volume_source() {
|
||||
pactl set-source-volume @DEFAULT_SOURCE@ "$1"
|
||||
CURRENT=$(pactl get-source-volume @DEFAULT_SOURCE@ | awk -F'/' '{ print $2 }' | tr -d ' %')
|
||||
notify-send -a "System Volume" -r 1001 -u low -i audio-volume-high -h int:progress:"$CURRENT" "Input Volume: $\{CURRENT\}%"
|
||||
}
|
||||
|
||||
bluetooth() {
|
||||
SPEAKER=$(pactl list sinks | grep "Name" | grep "blue" | awk -F ': ' '{ print $2 }')
|
||||
if [ "$SPEAKER" != "" ]; then
|
||||
pactl set-default-sink "$SPEAKER"
|
||||
pactl set-sink-mute "$SPEAKER" false
|
||||
DEVICE=$(echo "$SPEAKER" | awk -F '.' ' { print $4 } ')
|
||||
notify-send "changed audio to "$DEVICE" "
|
||||
else
|
||||
notify-send "failed, not available!"
|
||||
fi
|
||||
}
|
||||
|
||||
mute() {
|
||||
pactl set-sink-mute @DEFAULT_SINK@ toggle
|
||||
MUTE=$(pactl get-sink-mute @DEFAULT_SINK@)
|
||||
notify-send -a "Audio" -r 994 -u low -i audio-volume-high "Audio: $MUTE"
|
||||
}
|
||||
|
||||
if [ "$1" == "internal" ]; then
|
||||
internal
|
||||
elif [ "$1" == "bluetooth" ]; then
|
||||
bluetooth
|
||||
elif [ "$1" == "firefox" ]; then
|
||||
firefox "$2"
|
||||
elif [ "$1" == "ncspot" ]; then
|
||||
ncspot "$2"
|
||||
elif [ "$1" == "mute" ]; then
|
||||
mute
|
||||
elif [ "$1" == "sink" ]; then
|
||||
set_volume_sink "$2"
|
||||
elif [ "$1" == "source" ]; then
|
||||
set_volume_source "$2"
|
||||
fi
|
||||
''))
|
||||
] ++ config.mods.scripts.scripts;
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue