Skip to content

Commit

Permalink
Merge branch 'Jas-SinghFSU:master' into monitor-id-workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
Sawy7 authored Jan 18, 2025
2 parents f2f7c1b + 88609f7 commit 8267ec2
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 39 deletions.
92 changes: 60 additions & 32 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,23 @@ let
package = if pkgs ? hyprpanel then pkgs.hyprpanel
else abort ''
******************************************
* HyprPanel *
******************************************
* You didn't add the overlay! *
* *
* Either set 'overlay.enable = true' or *
* manually add it to 'nixpkgs.overlays'. *
******************************************
********************************************************************************
* HyprPanel *
*------------------------------------------------------------------------------*
* You didn't add the overlay! *
* *
* Either set 'overlay.enable = true' or manually add it to 'nixpkgs.overlays'. *
* If you use the 'nixosModule' for Home Manager and have 'useGlobalPkgs' set, *
* you will need to add the overlay yourself. *
********************************************************************************
'';

# Shorthand lambda for self-documenting options under settings
mkStrOption = default: mkOption { type = types.str; default = default; };
mkIntOption = default: mkOption { type = types.int; default = default; };
mkBoolOption = default: mkOption { type = types.bool; default = default; };
mkStrListOption = default: mkOption { type = types.listOf types.str; default = default; };
mkFloatOption = default: mkOption { type = types.float; default = default; };

# TODO: Please merge https://github.com/Jas-SinghFSU/HyprPanel/pull/497
# Do not ask what these do...
Expand Down Expand Up @@ -75,6 +78,7 @@ in
{
options.programs.hyprpanel = {
enable = mkEnableOption "HyprPanel";
config.enable = mkBoolOption true; # Generate config
overlay.enable = mkEnableOption "script overlay";
systemd.enable = mkEnableOption "systemd integration";
hyprland.enable = mkEnableOption "Hyprland integration";
Expand All @@ -97,7 +101,7 @@ in
'';
description = ''
An arbitrary set to override the final config with.
Useful for overriding colors in your selected theme.
Useful for overriding colors in your chosen theme.
'';
};

Expand Down Expand Up @@ -149,6 +153,25 @@ in
bar.clock.scrollUp = mkStrOption "";
bar.clock.showIcon = mkBoolOption true;
bar.clock.showTime = mkBoolOption true;
bar.customModules.cava.showIcon = mkBoolOption true;
bar.customModules.cava.icon = mkStrOption "";
bar.customModules.cava.spaceCharacter = mkStrOption " ";
bar.customModules.cava.barCharacters = mkStrListOption [ "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█" ];
bar.customModules.cava.showActiveOnly = mkBoolOption false;
bar.customModules.cava.bars = mkIntOption 10;
bar.customModules.cava.channels = mkIntOption 2;
bar.customModules.cava.framerate = mkIntOption 60;
bar.customModules.cava.samplerate = mkIntOption 44100;
bar.customModules.cava.autoSensitivity = mkBoolOption true;
bar.customModules.cava.lowCutoff = mkIntOption 50;
bar.customModules.cava.highCutoff = mkIntOption 10000;
bar.customModules.cava.noiseReduction = mkFloatOption 0.77;
bar.customModules.cava.stereo = mkBoolOption false;
bar.customModules.cava.leftClick = mkStrOption "";
bar.customModules.cava.rightClick = mkStrOption "";
bar.customModules.cava.middleClick = mkStrOption "";
bar.customModules.cava.scrollUp = mkStrOption "";
bar.customModules.cava.scrollDown = mkStrOption "";
bar.customModules.cpu.icon = mkStrOption "";
bar.customModules.cpu.label = mkBoolOption true;
bar.customModules.cpu.leftClick = mkStrOption "";
Expand Down Expand Up @@ -333,7 +356,8 @@ in
bar.workspaces.workspaces = mkIntOption 5;
dummy = mkBoolOption true;
hyprpanel.restartAgs = mkBoolOption true;
hyprpanel.restartCommand = mkStrOption "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel; ${package}/bin/hyprpanel";
# hyprpanel.restartCommand = mkStrOption "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel; ${package}/bin/hyprpanel";
hyprpanel.restartCommand = mkStrOption "${package}/bin/hyprpanel q; ${package}/bin/hyprpanel";
menus.clock.time.hideSeconds = mkBoolOption false;
menus.clock.time.military = mkBoolOption false;
menus.clock.weather.enabled = mkBoolOption true;
Expand Down Expand Up @@ -476,6 +500,7 @@ in
theme.bar.buttons.workspaces.fontSize = mkStrOption "1.2em";
theme.bar.buttons.workspaces.numbered_active_highlight_border = mkStrOption "0.2em";
theme.bar.buttons.workspaces.numbered_active_highlight_padding = mkStrOption "0.2em";
theme.bar.buttons.workspaces.numbered_inactive_padding = mkStrOption "0.2em";
theme.bar.buttons.workspaces.pill.active_width = mkStrOption "12em";
theme.bar.buttons.workspaces.pill.height = mkStrOption "4em";
theme.bar.buttons.workspaces.pill.radius = mkStrOption "1.9rem * 0.6";
Expand Down Expand Up @@ -580,7 +605,6 @@ in
text = ''
cd
echo '------------- HyprPanel -------------'
echo
echo 'Please ignore the layout diff for now'
echo '-------------------------------------'
colordiff ${config.xdg.configFile.hyprpanel.target} \
Expand All @@ -590,7 +614,8 @@ in

in mkIf cfg.enable {

nixpkgs.overlays = if cfg.overlay.enable then [ self.overlay ] else null;
# nixpkgs.overlays = if cfg.overlay.enable then [ self.overlay ] else null;
nixpkgs.overlays = lib.optionals cfg.overlay.enable [ self.overlay ];

home.packages = [
package
Expand All @@ -611,34 +636,37 @@ in
'';
};

xdg.configFile.hyprpanel = {
xdg.configFile.hyprpanel = mkIf cfg.config.enable {
target = "hyprpanel/config.json";
text = finalConfig;
onChange = "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel || true";
# onChange = "${pkgs.procps}/bin/pkill -u $USER -USR1 hyprpanel || true";
onChange = "${package}/bin/hyprpanel r";
};

xdg.configFile.hyprpanel-swap = {
xdg.configFile.hyprpanel-swap = mkIf cfg.config.enable {
target = "hyprpanel/config.hm.json";
text = finalConfig;
};

systemd.user.services = mkIf cfg.systemd.enable {
hyprpanel = {
Unit = {
Description = "A Bar/Panel for Hyprland with extensive customizability.";
Documentation = "https://hyprpanel.com";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session-pre.target" ];
};
Service = {
ExecStart = "${package}/bin/hyprpanel";
ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR1 $MAINPID";
Restart = "on-failure";
KillMode = "mixed";
};
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
# NOTE: Deprecated
# systemd.user.services = mkIf cfg.systemd.enable {
# hyprpanel = {
# Unit = {
# Description = "A Bar/Panel for Hyprland with extensive customizability.";
# Documentation = "https://hyprpanel.com";
# PartOf = [ "graphical-session.target" ];
# After = [ "graphical-session-pre.target" ];
# };
# Service = {
# ExecStart = "${package}/bin/hyprpanel";
# ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR1 $MAINPID";
# Restart = "on-failure";
# KillMode = "mixed";
# };
# Install = { WantedBy = [ "graphical-session.target" ]; };
# };
# };
warnings = if cfg.systemd.enable then [ "The `systemd.enable` option is now obsolete." ] else [];

wayland.windowManager.hyprland.settings.exec-once = mkIf cfg.hyprland.enable [ "${package}/bin/hyprpanel" ];
};
Expand Down
7 changes: 3 additions & 4 deletions src/components/bar/modules/notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import { BarBoxChild } from 'src/lib/types/bar.js';
import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/utils/helpers.js';
import { bind, Variable } from 'astal';
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers';
import { notifdService } from 'src/lib/constants/services';

const { show_total, rightClick, middleClick, scrollUp, scrollDown, hideCountWhenZero } = options.bar.notifications;
const { ignore } = options.notifications;

const notifs = AstalNotifd.get_default();

export const Notifications = (): BarBoxChild => {
const componentClassName = Variable.derive(
[bind(options.theme.bar.buttons.style), bind(show_total)],
Expand All @@ -29,8 +28,8 @@ export const Notifications = (): BarBoxChild => {

const boxChildren = Variable.derive(
[
bind(notifs, 'notifications'),
bind(notifs, 'dontDisturb'),
bind(notifdService, 'notifications'),
bind(notifdService, 'dontDisturb'),
bind(show_total),
bind(ignore),
bind(hideCountWhenZero),
Expand Down
3 changes: 2 additions & 1 deletion src/components/bar/modules/power/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import options from 'src/options';
import { Module } from '../../shared/Module';
import { inputHandler } from 'src/components/bar/utils/helpers';
import { BarBoxChild } from 'src/lib/types/bar';
import { bind } from 'astal';
import { bind, Variable } from 'astal';
import { Astal } from 'astal/gtk3';

const { icon, leftClick, rightClick, middleClick, scrollUp, scrollDown } = options.bar.customModules.power;
Expand All @@ -11,6 +11,7 @@ export const Power = (): BarBoxChild => {
const powerModule = Module({
tooltipText: 'Power Menu',
textIcon: bind(icon),
showLabelBinding: Variable(false),
boxClass: 'powermodule',
props: {
setup: (self: Astal.Button) => {
Expand Down
6 changes: 6 additions & 0 deletions src/components/settings/pages/config/bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ export const BarSettings = (): JSX.Element => {
subtitle="Only applicable if Workspace Numbers are enabled"
type="string"
/>
<Option
opt={options.theme.bar.buttons.workspaces.numbered_inactive_padding}
title="Inactive Padding"
subtitle="Only applicable if Workspace Numbers are enabled"
type="string"
/>
<Option
opt={options.theme.bar.buttons.workspaces.pill.radius}
title="Pill Radius"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function icon(name: string | null, fallback = icons.missing): string {

if (lookUpIcon(icon)) return icon;

print(`no icon substitute "${icon}" for "${name}", fallback: "${fallback}"`);
console.log(`no icon substitute "${icon}" for "${name}", fallback: "${fallback}"`);
return fallback;
}

Expand Down
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ const options = mkOptions(CONFIG, {
hover: opt(colors.pink),
numbered_active_highlight_border: opt('0.2em'),
numbered_active_highlight_padding: opt('0.2em'),
numbered_inactive_padding: opt('0.2em'),
numbered_active_highlighted_text_color: opt(colors.mantle),
numbered_active_underline_color: opt(colors.pink),
spacing: opt('0.5em'),
Expand Down
2 changes: 1 addition & 1 deletion src/scss/style/bar/workspace.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
min-height: 0em;
border-radius: 0em;
transition: 0ms;
padding: 0em 0.2em;
padding: 0em $bar-buttons-workspaces-numbered_inactive_padding;
font-size: $bar-buttons-workspaces-fontSize;
}

Expand Down

0 comments on commit 8267ec2

Please sign in to comment.