From 142ad87364414c08b339e79c9186cbca4bafabb3 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 20 Jun 2024 14:53:31 +0200 Subject: [PATCH 1/4] Fix shebang in eww scripts --- .../bars/eww/config/scripts/gammarelay | 120 ++++++++--------- .../graphical/bars/eww/config/scripts/include | 2 +- .../bars/eww/config/scripts/nightlight | 4 +- .../graphical/bars/eww/config/scripts/storage | 36 ++--- .../graphical/bars/eww/config/scripts/temp | 2 +- .../graphical/bars/eww/config/scripts/volume | 124 +++++++++--------- .../bars/eww/config/scripts/window_name | 2 +- .../bars/eww/config/scripts/workspaces | 10 +- 8 files changed, 150 insertions(+), 150 deletions(-) diff --git a/home/programs/graphical/bars/eww/config/scripts/gammarelay b/home/programs/graphical/bars/eww/config/scripts/gammarelay index 039dbea..79f1ec4 100755 --- a/home/programs/graphical/bars/eww/config/scripts/gammarelay +++ b/home/programs/graphical/bars/eww/config/scripts/gammarelay @@ -1,82 +1,82 @@ -#!/bin/env bash +#!/usr/bin/env bash if [ "$1" = "temperature" ]; then - watch_cmd="{t}" - update_cmd="UpdateTemperature" - update_signature="n" - set_cmd="Temperature" - set_signature="q" - default_val=6500 - click_val=4500 - scroll_change=100 - cmp_op="<" + watch_cmd="{t}" + update_cmd="UpdateTemperature" + update_signature="n" + set_cmd="Temperature" + set_signature="q" + default_val=6500 + click_val=4500 + scroll_change=100 + cmp_op="<" elif [ "$1" = "brightness" ]; then - watch_cmd="{bp}" - update_cmd="UpdateBrightness" - update_signature="d" - set_cmd="Brightness" - set_signature="d" - default_val=1 - click_val=0.8 - scroll_change=0.02 - cmp_op="<" + watch_cmd="{bp}" + update_cmd="UpdateBrightness" + update_signature="d" + set_cmd="Brightness" + set_signature="d" + default_val=1 + click_val=0.8 + scroll_change=0.02 + cmp_op="<" elif [ "$1" = "gamma" ]; then - watch_cmd="{g}" - update_cmd="UpdateGamma" - update_signature="d" - set_cmd="Gamma" - set_signature="d" - default_val=1 - click_val=1.1 - scroll_change=0.02 - cmp_op=">" + watch_cmd="{g}" + update_cmd="UpdateGamma" + update_signature="d" + set_cmd="Gamma" + set_signature="d" + default_val=1 + click_val=1.1 + scroll_change=0.02 + cmp_op=">" else - >&2 echo "Invalid option, first argument must be one of: temperature, brightness, gamma" - exit 1 + >&2 echo "Invalid option, first argument must be one of: temperature, brightness, gamma" + exit 1 fi if [ "$2" = "watch" ]; then - exec wl-gammarelay-rs watch "$watch_cmd" + exec wl-gammarelay-rs watch "$watch_cmd" elif [ "$2" = "get" ]; then - exec busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2 + exec busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2 elif [ "$2" = "scroll" ]; then - if [ "$3" = "up" ]; then - sign="+" - elif [ "$3" = "down" ]; then - sign="-" - else - >&2 echo "Invalid sign, second argument must be one of: up, down" - exit 1 - fi + if [ "$3" = "up" ]; then + sign="+" + elif [ "$3" = "down" ]; then + sign="-" + else + >&2 echo "Invalid sign, second argument must be one of: up, down" + exit 1 + fi - exec busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay "$update_cmd" "$update_signature" ${sign}${scroll_change} + exec busctl --user -- call rs.wl-gammarelay / rs.wl.gammarelay "$update_cmd" "$update_signature" ${sign}${scroll_change} elif [ "$2" = "set" ]; then - mode="$3" - if [ "$mode" = "toggle" ]; then - cur_val="$(busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2)" - if [ "$(echo "$cur_val $cmp_op $default_val" | bc -l)" = "1" ]; then - mode="off" - else - mode="on" - fi - fi + mode="$3" + if [ "$mode" = "toggle" ]; then + cur_val="$(busctl --user get-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" | cut -d' ' -f2)" + if [ "$(echo "$cur_val $cmp_op $default_val" | bc -l)" = "1" ]; then + mode="off" + else + mode="on" + fi + fi - if [ "$mode" = "on" ]; then - exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$click_val" - elif [ "$mode" = "off" ]; then - exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$default_val" - else - >&2 echo "Invalid mode, third argument, must be one of: toggle, on, off" - exit 1 - fi + if [ "$mode" = "on" ]; then + exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$click_val" + elif [ "$mode" = "off" ]; then + exec busctl --user -- set-property rs.wl-gammarelay / rs.wl.gammarelay "$set_cmd" "$set_signature" "$default_val" + else + >&2 echo "Invalid mode, third argument, must be one of: toggle, on, off" + exit 1 + fi else - >&2 echo "Invalid operation, second argument must be one of: watch, scroll, set" - exit 1 + >&2 echo "Invalid operation, second argument must be one of: watch, scroll, set" + exit 1 fi diff --git a/home/programs/graphical/bars/eww/config/scripts/include b/home/programs/graphical/bars/eww/config/scripts/include index 49e58e9..b67e164 100755 --- a/home/programs/graphical/bars/eww/config/scripts/include +++ b/home/programs/graphical/bars/eww/config/scripts/include @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash # $1: Current number # $2: Range minimum diff --git a/home/programs/graphical/bars/eww/config/scripts/nightlight b/home/programs/graphical/bars/eww/config/scripts/nightlight index 71522f0..5052dca 100644 --- a/home/programs/graphical/bars/eww/config/scripts/nightlight +++ b/home/programs/graphical/bars/eww/config/scripts/nightlight @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash # shellcheck source=include source "./scripts/include" @@ -8,5 +8,5 @@ source "./scripts/include" # not be enough. if [ "$1" = "toggle" ]; then - gammastep -x + gammastep -x fi diff --git a/home/programs/graphical/bars/eww/config/scripts/storage b/home/programs/graphical/bars/eww/config/scripts/storage index f1ff4b4..aded231 100755 --- a/home/programs/graphical/bars/eww/config/scripts/storage +++ b/home/programs/graphical/bars/eww/config/scripts/storage @@ -1,35 +1,35 @@ -#!/bin/env bash +#!/usr/bin/env bash MOUNTPOINTS=("/" "/mnt/ext") data="$(df -H)" as_json() { - mountpoint="$1" - res="$2" - arr_res=($res) + mountpoint="$1" + res="$2" + arr_res=($res) - jq -n -c --monochrome-output \ - --arg mountpoint "$mountpoint" \ - --arg size "${arr_res[0]}" \ - --arg used "${arr_res[1]}" \ - --arg avail "${arr_res[2]}" \ - --arg percent "${arr_res[3]}" \ - '$ARGS.named' + jq -n -c --monochrome-output \ + --arg mountpoint "$mountpoint" \ + --arg size "${arr_res[0]}" \ + --arg used "${arr_res[1]}" \ + --arg avail "${arr_res[2]}" \ + --arg percent "${arr_res[3]}" \ + '$ARGS.named' } output_json="[]" for mountpoint in "${MOUNTPOINTS[@]}"; do - res="$(echo "$data" | awk -v m="$mountpoint" '$6 == m {print $2 " " $3 " " $4 " " $5}')" - out="$(as_json "$mountpoint" "$res")" + res="$(echo "$data" | awk -v m="$mountpoint" '$6 == m {print $2 " " $3 " " $4 " " $5}')" + out="$(as_json "$mountpoint" "$res")" - # echo "$output_json $out" | jq -c -s + # echo "$output_json $out" | jq -c -s - jq --argjson arr1 "$output_json" --argjson arr2 "[$out]" -n \ - '$arr1 + $arr2' + jq --argjson arr1 "$output_json" --argjson arr2 "[$out]" -n \ + '$arr1 + $arr2' - # mount_data+=("$mountpoint" $res) - # echo "${mount_data[@]}" + # mount_data+=("$mountpoint" $res) + # echo "${mount_data[@]}" done # echo "${mount_data[@]}" diff --git a/home/programs/graphical/bars/eww/config/scripts/temp b/home/programs/graphical/bars/eww/config/scripts/temp index 3857531..b6cdd13 100755 --- a/home/programs/graphical/bars/eww/config/scripts/temp +++ b/home/programs/graphical/bars/eww/config/scripts/temp @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash # shellcheck source=include source "./scripts/include" diff --git a/home/programs/graphical/bars/eww/config/scripts/volume b/home/programs/graphical/bars/eww/config/scripts/volume index 6003f79..23cf284 100755 --- a/home/programs/graphical/bars/eww/config/scripts/volume +++ b/home/programs/graphical/bars/eww/config/scripts/volume @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash # Define some icons SPEAKER_ICONS=("" "" "") @@ -10,64 +10,64 @@ MIC_MUTED_ICON="" # $1 can either be "SINK" (speaker) or "SOURCE" (microphone) get_vol() { - wpctl get-volume "@DEFAULT_AUDIO_${1}@" | awk '{print int($2*100)}' + wpctl get-volume "@DEFAULT_AUDIO_${1}@" | awk '{print int($2*100)}' } # $1 can either be "SINK" (speaker) or "SOURCE" (microphone) # #2 is the voulme (as percentage) to set the volume to # $3 is optional, if set, it can be '+' or '-', which then adds/decreases volume, instead of setting set_vol() { - wpctl set-volume "@DEFAULT_AUDIO_${1}@" "$(awk -v n="$2" 'BEGIN{print (n / 100)}')$3" + wpctl set-volume "@DEFAULT_AUDIO_${1}@" "$(awk -v n="$2" 'BEGIN{print (n / 100)}')$3" } # $1 can either be "SINK" (speaker) or "SOURCE" (microphone) check_mute() { - wpctl get-volume "@DEFAULT_AUDIO_${1}@" | grep -i muted >/dev/null - echo $? + wpctl get-volume "@DEFAULT_AUDIO_${1}@" | grep -i muted >/dev/null + echo $? } # $1 can either be "SINK" (speaker) or "SOURCE" (microphone) toggle_mute() { - wpctl set-mute "@DEFAULT_AUDIO_${1}@" toggle + wpctl set-mute "@DEFAULT_AUDIO_${1}@" toggle } get_report() { - spkr_vol="$(get_vol "SINK")" - mic_vol="$(get_vol "SOURCE")" + spkr_vol="$(get_vol "SINK")" + mic_vol="$(get_vol "SOURCE")" - if [ "$(check_mute "SINK")" == "0" ]; then - spkr_mute="true" - spkr_icon="$SPEAKER_MUTED_ICON" - else - spkr_mute="false" - index="$(awk -v n="$spkr_vol" -v m="${#SPEAKER_ICONS[@]}" 'BEGIN{print int(n/(100/m))}')" + if [ "$(check_mute "SINK")" == "0" ]; then + spkr_mute="true" + spkr_icon="$SPEAKER_MUTED_ICON" + else + spkr_mute="false" + index="$(awk -v n="$spkr_vol" -v m="${#SPEAKER_ICONS[@]}" 'BEGIN{print int(n/(100/m))}')" - # We might end up with an higher than the length of icons, if the volume is over 100% - # in this case, set the index to last icon - if [ "$index" -ge "${#SPEAKER_ICONS[@]}" ]; then - spkr_icon="${SPEAKER_ICONS[-1]}" - else - spkr_icon="${SPEAKER_ICONS[$index]}" - fi - fi + # We might end up with an higher than the length of icons, if the volume is over 100% + # in this case, set the index to last icon + if [ "$index" -ge "${#SPEAKER_ICONS[@]}" ]; then + spkr_icon="${SPEAKER_ICONS[-1]}" + else + spkr_icon="${SPEAKER_ICONS[$index]}" + fi + fi - if [ "$(check_mute "SOURCE")" = "0" ]; then - mic_mute="true" - mic_icon="$MIC_MUTED_ICON" - else - mic_mute="false" - mic_icon="$MIC_ICON" - fi + if [ "$(check_mute "SOURCE")" = "0" ]; then + mic_mute="true" + mic_icon="$MIC_MUTED_ICON" + else + mic_mute="false" + mic_icon="$MIC_ICON" + fi - echo "{ \"speaker_vol\": \"$spkr_vol\", \"speaker_mute\": $spkr_mute, \"speaker_icon\": \"$spkr_icon\", \"microphone_mute\": $mic_mute, \"microphone_vol\": \"$mic_vol\", \"microphone_icon\": \"$mic_icon\" }" + echo "{ \"speaker_vol\": \"$spkr_vol\", \"speaker_mute\": $spkr_mute, \"speaker_icon\": \"$spkr_icon\", \"microphone_mute\": $mic_mute, \"microphone_vol\": \"$mic_vol\", \"microphone_icon\": \"$mic_icon\" }" } # Continually run and report every volume change (into stdout) loop() { - get_report - pactl subscribe | grep --line-buffered "change" | while read -r _; do - get_report - done + get_report + pactl subscribe | grep --line-buffered "change" | while read -r _; do + get_report + done } case "$1" in @@ -76,37 +76,37 @@ case "$1" in "once") get_report ;; "togglemute") - if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then - >&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'" - exit 1 - fi - toggle_mute "$2" - ;; + if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then + >&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'" + exit 1 + fi + toggle_mute "$2" + ;; "setvol") - if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then - >&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'" - exit 1 - fi + if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then + >&2 echo "Invalid usage, expected second argument to be 'SINK' or 'SOURCE', got '$2'" + exit 1 + fi - if [[ "$3" =~ ^[+-]?[0-9]*\.?[0-9]+$ ]]; then - case "$4" in - "") set_vol "$2" "$3" ;; - up | +) set_vol "$2" "$3" "+" ;; - down | -) set_vol "$2" "$3" "-" ;; - *) - >&2 echo "Invalid usage, expected fourth argument to be up/down or +/-, got '$4'" - exit 1 - ;; - esac - else - >&2 echo "Invalid usage, exepcted third argument to be a number, got '$3'" - exit 1 - fi - ;; + if [[ "$3" =~ ^[+-]?[0-9]*\.?[0-9]+$ ]]; then + case "$4" in + "") set_vol "$2" "$3" ;; + up | +) set_vol "$2" "$3" "+" ;; + down | -) set_vol "$2" "$3" "-" ;; + *) + >&2 echo "Invalid usage, expected fourth argument to be up/down or +/-, got '$4'" + exit 1 + ;; + esac + else + >&2 echo "Invalid usage, exepcted third argument to be a number, got '$3'" + exit 1 + fi + ;; *) - >&2 echo "Invalid usage, argument '$1' not recognized." - exit 1 - ;; + >&2 echo "Invalid usage, argument '$1' not recognized." + exit 1 + ;; esac diff --git a/home/programs/graphical/bars/eww/config/scripts/window_name b/home/programs/graphical/bars/eww/config/scripts/window_name index d32bff7..f9e8a59 100755 --- a/home/programs/graphical/bars/eww/config/scripts/window_name +++ b/home/programs/graphical/bars/eww/config/scripts/window_name @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash # shellcheck source=include source "./scripts/include" diff --git a/home/programs/graphical/bars/eww/config/scripts/workspaces b/home/programs/graphical/bars/eww/config/scripts/workspaces index 992b7ab..903182e 100755 --- a/home/programs/graphical/bars/eww/config/scripts/workspaces +++ b/home/programs/graphical/bars/eww/config/scripts/workspaces @@ -1,13 +1,13 @@ -#!/bin/env bash +#!/usr/bin/env bash # shellcheck source=include source "./scripts/include" if [ "$1" = "--switch" ]; then - $HOME/.local/bin/scripts/gui/hyprland/swap-workspace "$2" >/dev/null - # hyprctl dispatch workspace "$2" >/dev/null + $HOME/.local/bin/scripts/gui/hyprland/swap-workspace "$2" >/dev/null + # hyprctl dispatch workspace "$2" >/dev/null elif [ "$1" = "--loop" ]; then - hyprland_ipc "workspace|createworkspace|destroyworkspace" | ./scripts/workspaces.py "$@" + hyprland_ipc "workspace|createworkspace|destroyworkspace" | ./scripts/workspaces.py "$@" else - ./scripts/workspaces.py "$@" + ./scripts/workspaces.py "$@" fi From b55b49c842c0b96c11932fa5d38b713fbc28eea1 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 20 Jun 2024 14:53:40 +0200 Subject: [PATCH 2/4] Persist zoxide db --- hosts/voyager/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 393f3e7..a1ce215 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -63,6 +63,7 @@ ".mullvad" ".config/chromium" ".local/share/gnupg" + ".local/share/zoxide" ".local/share/wakatime" ".local/share/nvim" ".local/state/nvim" From f726805e5caadeab94f0503b25625d6a432904db Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 20 Jun 2024 15:00:00 +0200 Subject: [PATCH 3/4] Add stremio --- home/packages/gui/default.nix | 1 + home/packages/gui/stremio.nix | 17 +++++++++++++++++ hosts/voyager/default.nix | 1 + options/home/programs/default.nix | 1 + 4 files changed, 20 insertions(+) create mode 100644 home/packages/gui/stremio.nix diff --git a/home/packages/gui/default.nix b/home/packages/gui/default.nix index e0d4165..83ea62f 100644 --- a/home/packages/gui/default.nix +++ b/home/packages/gui/default.nix @@ -1,5 +1,6 @@ _: { imports = [ ./wayland.nix + ./stremio.nix ]; } diff --git a/home/packages/gui/stremio.nix b/home/packages/gui/stremio.nix new file mode 100644 index 0000000..1ad2144 --- /dev/null +++ b/home/packages/gui/stremio.nix @@ -0,0 +1,17 @@ +{ + lib, + pkgs, + osConfig, + ... +}: let + inherit (lib) mkIf; + + cfg = osConfig.myOptions.home-manager.programs.stremio; +in { + config = mkIf cfg.enable { + home.packages = with pkgs; [ + stremio + ]; + }; +} + diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index a1ce215..8e98428 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -136,6 +136,7 @@ mullvad-browser.enable = true; }; spotify.enable = true; + stremio.enable = true; }; }; }; diff --git a/options/home/programs/default.nix b/options/home/programs/default.nix index ebb153c..594e834 100644 --- a/options/home/programs/default.nix +++ b/options/home/programs/default.nix @@ -27,5 +27,6 @@ in }; spotify.enable = mkEnableOption "Spotify"; + stremio.enable = mkEnableOption "Stremio free media center"; }; } From d3a40dd75959bca1ca98b08bedcaa67c94291998 Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Thu, 20 Jun 2024 15:37:46 +0200 Subject: [PATCH 4/4] Add vesktop --- home/programs/graphical/apps/default.nix | 1 + .../graphical/apps/vesktop/default.nix | 34 +++++++++++++++++++ hosts/voyager/default.nix | 5 +++ options/home/programs/default.nix | 4 +++ 4 files changed, 44 insertions(+) create mode 100644 home/programs/graphical/apps/vesktop/default.nix diff --git a/home/programs/graphical/apps/default.nix b/home/programs/graphical/apps/default.nix index a2cb1cb..df8e966 100644 --- a/home/programs/graphical/apps/default.nix +++ b/home/programs/graphical/apps/default.nix @@ -1,5 +1,6 @@ _: { imports = [ ./spotify + ./vesktop ]; } diff --git a/home/programs/graphical/apps/vesktop/default.nix b/home/programs/graphical/apps/vesktop/default.nix new file mode 100644 index 0000000..ead6064 --- /dev/null +++ b/home/programs/graphical/apps/vesktop/default.nix @@ -0,0 +1,34 @@ +{ + lib, + osConfig, + pkgs, + ... +}: let + inherit (lib) mkIf; + + cfg = osConfig.myOptions.home-manager.programs.vesktop; +in { + config = mkIf cfg.enable { + home.packages = with pkgs; [ vesktop ]; + + xdg.configFile = { + "vesktop/settings.json".text = builtins.toJSON { + discordBranch = "stable"; # consider "ptb" + firstLaunch = false; + arRPC = "on"; + splashColor = "rgb(219, 222, 225)"; + splashBackground = "rgb(49, 51, 56)"; + checkUpdates = false; + staticTitle = true; + disableMinSize = true; + minimizeToTray = false; + tray = false; + appBadge = false; + }; + + "autostart/vesktop.desktop" = mkIf cfg.autoStart { + source = "${pkgs.vesktop}/share/applications/vesktop.desktop"; + }; + }; + }; +} diff --git a/hosts/voyager/default.nix b/hosts/voyager/default.nix index 8e98428..2aeb09d 100644 --- a/hosts/voyager/default.nix +++ b/hosts/voyager/default.nix @@ -62,6 +62,7 @@ ".mozilla" ".mullvad" ".config/chromium" + ".config/vesktop" ".local/share/gnupg" ".local/share/zoxide" ".local/share/wakatime" @@ -137,6 +138,10 @@ }; spotify.enable = true; stremio.enable = true; + vesktop = { + enable = true; + autoStart = true; + }; }; }; }; diff --git a/options/home/programs/default.nix b/options/home/programs/default.nix index 594e834..f271c18 100644 --- a/options/home/programs/default.nix +++ b/options/home/programs/default.nix @@ -28,5 +28,9 @@ in spotify.enable = mkEnableOption "Spotify"; stremio.enable = mkEnableOption "Stremio free media center"; + vesktop = { + enable = mkEnableOption "Vesktop (An alternate client for Discord with Vencord built-in)"; + autoStart = mkEnableOption "Auto-Start for Vesktop"; + }; }; }