q: highlight risky users

This commit is contained in:
Ingolf Wagner 2020-01-02 11:49:44 +13:00
parent 6bf95c6948
commit 702d85b329
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
3 changed files with 15 additions and 3 deletions

View file

@ -23,6 +23,10 @@ in {
default = true; default = true;
type = with types; bool; type = with types; bool;
}; };
userHighlight = mkOption {
default = [ config.users.users.mainUser.name ];
type = with types; listOf str;
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -31,6 +35,7 @@ in {
timeZones = cfg.timeZones; timeZones = cfg.timeZones;
enableIntelBacklight = cfg.enableIntelBacklight; enableIntelBacklight = cfg.enableIntelBacklight;
enableBattery = cfg.enableBattery; enableBattery = cfg.enableBattery;
userHighlight = cfg.userHighlight;
}) })
]; ];
}; };

View file

@ -2,7 +2,7 @@
# tzselect is your frind do find timezones # tzselect is your frind do find timezones
, timeZones ? [ ], timeColor ? 9, timeZoneColor ? 10, calBackgroundColor ? 10 , timeZones ? [ ], timeColor ? 9, timeZoneColor ? 10, calBackgroundColor ? 10
, calWeekColor ? 13, calDayColor ? 9, enableIntelBacklight ? true , calWeekColor ? 13, calDayColor ? 9, enableIntelBacklight ? true
, enableBattery ? true, ... }: , userHighlight ? [ "palo" ], enableBattery ? true, ... }:
let let
@ -296,11 +296,13 @@ let
''; '';
q-show-users = '' q-show-users = ''
${pkgs.procps}/bin/ps aux \ ${pkgs.procps}/bin/ps -eo user \
| ${pkgs.gawk}/bin/awk '{ print $1 }' \
| ${pkgs.gnused}/bin/sed '1 d' \ | ${pkgs.gnused}/bin/sed '1 d' \
| ${pkgs.coreutils}/bin/sort \ | ${pkgs.coreutils}/bin/sort \
| ${pkgs.coreutils}/bin/uniq \ | ${pkgs.coreutils}/bin/uniq \
| ${pkgs.gnugrep}/bin/egrep --color=always '(${
lib.concatStringsSep "|" userHighlight
})|$' \
| ${pkgs.utillinux}/bin/column | ${pkgs.utillinux}/bin/column
''; '';

View file

@ -57,4 +57,9 @@ in {
}; };
}; };
# highlight browser users in q command
programs.custom.q.userHighlight = map ({ user, ... }: user)
(builtins.attrValues config.programs.custom.browser.configList);
} }