a lot of improvements on desktop stuff

This commit is contained in:
Gabriel Fontes
2022-06-30 02:49:20 -03:00
parent d2f6286f58
commit 9767a4e85e
17 changed files with 357 additions and 228 deletions
Generated
+9 -9
View File
@@ -98,11 +98,11 @@
"wlroots": "wlroots"
},
"locked": {
"lastModified": 1656425567,
"narHash": "sha256-1ViJAzwtK0xYUMmECR+JIsXtUIeANqycmYkDHwL6HTc=",
"lastModified": 1656538431,
"narHash": "sha256-4sYenC7/ZxceNTcAYlHxl6+SHp2T4+v5r1BvhprHL9w=",
"owner": "hyprwm",
"repo": "hyprland",
"rev": "6213328d2cba771aa8db4379d6ec88bf15f103d9",
"rev": "ae3ff6736e6e9a8e7d06f3706c0c4786b37ec3bb",
"type": "github"
},
"original": {
@@ -146,11 +146,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1656239181,
"narHash": "sha256-wW1xRFBn376yGloXZ4QzBE4hjipMawpV18Lshd9QSPw=",
"lastModified": 1656372800,
"narHash": "sha256-1u9SDLXvKix/QejNb2sY2J2QZXnbe/14MnLtn+ln9j0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f2537a505d45c31fe5d9c27ea9829b6f4c4e6ac5",
"rev": "020c74014b9e2fa905bb4059c979965816cd9118",
"type": "github"
},
"original": {
@@ -194,11 +194,11 @@
},
"nur": {
"locked": {
"lastModified": 1656440741,
"narHash": "sha256-Apn2V5plV2vNHj4JrwClsI67H+Ab/7QmVDXPVaf0L3I=",
"lastModified": 1656516558,
"narHash": "sha256-xMfUEwRG1ty4YysAl0BNlHbdLPxbi8cCFmCOTt4JLFA=",
"owner": "nix-community",
"repo": "NUR",
"rev": "c77b7b770d126310e79a847e2ef06d6a8a2e4a19",
"rev": "e86ce90db1b2ee55ba412845161c063dff3301db",
"type": "github"
},
"original": {
+4 -4
View File
@@ -101,8 +101,8 @@
inherit packages;
username = "misterio";
hostname = "atlas";
colorscheme = "spaceduck";
wallpaper = "clouds-moon-painting-purple";
wallpaper = "painting-river-snow-forest-gold";
colorscheme = "phd";
persistence = true;
desktop = "hyprland";
features = [
@@ -144,8 +144,8 @@
inherit packages;
username = "misterio";
system = "x86_64-linux";
colorscheme = "phd";
features = [ "desktop/gnome" ];
colorscheme = "dracula";
desktop = "gnome";
};
# GELOS lab computers
+1
View File
@@ -9,6 +9,7 @@
./gtk.nix
./kdeconnect.nix
./pavucontrol.nix
./playerctl.nix
./qt.nix
./sublime-music.nix
];
@@ -0,0 +1,7 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [ playerctl ];
services.playerctld = {
enable = true;
};
}
@@ -1,21 +1,27 @@
{ config, features, lib, pkgs, mylib, desktop ? "graphical", ... }:
{ config, features, lib, pkgs, mylib, desktop, ... }:
let
trusted = mylib.has "trusted" features;
jsonOutput = { pre ? "", text ? "", tooltip ? "", alt ? "", class ? "", percentage ? "" }:
let jq = "${pkgs.jq}/bin/jq"; in
''
${pre}
${jq} -cn \
--arg text "${text}" \
--arg tooltip "${tooltip}" \
--arg alt "${alt}" \
--arg class "${class}" \
--arg percentage "${percentage}" \
'{text:$text,tooltip:$tooltip,alt:$alt,class:$class,percentage:$percentage}'
'';
jsonOutput = { pre ? "", text ? "", tooltip ? "", alt ? "", class ? "", percentage ? "" }: ''
${pre}
${jq} -cn \
--arg text "${text}" \
--arg tooltip "${tooltip}" \
--arg alt "${alt}" \
--arg class "${class}" \
--arg percentage "${percentage}" \
'{text:$text,tooltip:$tooltip,alt:$alt,class:$class,percentage:$percentage}'
'';
inherit (builtins) attrValues concatStringsSep mapAttrs;
inherit (pkgs.lib) optionals;
# Dependencies
jq = "${pkgs.jq}/bin/jq";
wofi = "${pkgs.wofi}/bin/wofi";
xml = "${pkgs.xmlstarlet}/bin/xml";
gamemoded = "${pkgs.gamemode}/bin/gamemoded";
systemctl = "${pkgs.systemd}/bin/systemctl";
playerctl = "${pkgs.playerctl}/bin/playerctl";
in
{
programs. waybar = {
@@ -32,7 +38,7 @@ in
]) ++ (optionals (desktop == "hyprland") [
"wlr/workspaces"
]) ++ [
"custom/preferredplayer"
"custom/currentplayer"
"custom/player"
];
modules-center = [
@@ -42,11 +48,11 @@ in
"clock"
"pulseaudio"
"custom/unread-mail"
"custom/gammastep"
"custom/gpg-agent"
];
modules-right = [
"custom/gamemode"
"custom/gammastep"
"custom/theme"
"network"
"custom/home"
@@ -65,7 +71,7 @@ in
};
memory = {
format = " {}%";
interval = 4;
interval = 5;
};
pulseaudio = {
format = "{icon} {volume}%";
@@ -79,7 +85,7 @@ in
};
battery = {
bat = "BAT0";
interval = 40;
interval = 5;
format-icons = [ "" "" "" "" "" "" "" "" "" "" ];
format = "{icon} {capacity}%";
format-charging = " {capacity}%";
@@ -121,7 +127,7 @@ in
let
display = if (title == null) then icon else "${icon} ${title}:";
in
''${display} $(ping -qc5 ${host} 2>&1 | awk -F/ '/^rtt/ { printf "%.2fms", $5; ok = 1 } END { if (!ok) print "Disconnected" }')'';
''${display} $(ping -qc4 ${host} 2>&1 | awk -F/ '/^rtt/ { printf "%.2fms", $5; ok = 1 } END { if (!ok) print "Disconnected" }')'';
targets = {
web = { host = "9.9.9.9"; icon = " "; };
@@ -142,7 +148,7 @@ in
text = "";
tooltip = ''$(cat /etc/os-release | grep PRETTY_NAME | cut -d '"' -f2)'';
};
on-click = "${pkgs.wofi}/bin/wofi -S drun";
on-click = "${wofi} -S drun";
};
"custom/hostname" = {
return-type = "json";
@@ -154,23 +160,19 @@ in
interval = 5;
return-type = "json";
exec = jsonOutput {
pre =
let
xml = "${pkgs.xmlstarlet}/bin/xml";
in
''
count=$(find ~/Mail/*/INBOX/new -type f | wc -l)
if [ "$count" == "0" ]; then
subjects="No new mail"
status="read"
else
subjects=$(\
grep -h "Subject: " -r ~/Mail/*/INBOX/new | cut -d ':' -f2- | \
perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | ${xml} esc | sed -e 's/^/\-/'\
)
status="unread"
fi
'';
pre = ''
count=$(find ~/Mail/*/INBOX/new -type f | wc -l)
if [ "$count" == "0" ]; then
subjects="No new mail"
status="read"
else
subjects=$(\
grep -h "Subject: " -r ~/Mail/*/INBOX/new | cut -d ':' -f2- | \
perl -CS -MEncode -ne 'print decode("MIME-Header", $_)' | ${xml} esc | sed -e 's/^/\-/'\
)
status="unread"
fi
'';
text = "$count";
tooltip = "$subjects";
alt = "$status";
@@ -182,7 +184,7 @@ in
};
};
"custom/gpg-agent" = lib.mkIf trusted {
interval = 3;
interval = 2;
return-type = "json";
exec =
let
@@ -200,17 +202,33 @@ in
};
};
"custom/gamemode" = {
exec-if =
"${pkgs.gamemode}/bin/gamemoded --status | grep 'is active' -q";
interval = 3;
exec-if = "${gamemoded} --status | grep 'is active' -q";
interval = 2;
return-type = "json";
exec = jsonOutput {
tooltip = "Gamemode is active";
};
format = " ";
};
"custom/gammastep" = {
interval = 2;
return-type = "json";
exec = jsonOutput {
pre = "status=$(${systemctl} is-active gammastep)";
alt = "$status";
tooltip = "Gammastep is $status";
};
format = "{icon}";
format-icons = {
"active" = " ";
"activating" = "...";
"inactive" = " ";
"deactivating" = "...";
};
on-click = "${systemctl} is-active gammastep --quiet && ${systemctl} stop gammastep || ${systemctl} start gammastep";
};
"custom/theme" = {
interval = 10;
interval = 5;
return-type = "json";
max-length = 20;
exec = jsonOutput {
@@ -220,7 +238,7 @@ in
format = " {}";
};
"custom/gpu" = {
interval = 3;
interval = 5;
return-type = "json";
exec = jsonOutput {
text = "$(cat /sys/class/drm/card0/device/gpu_busy_percent)";
@@ -228,11 +246,11 @@ in
};
format = " {}%";
};
"custom/preferredplayer" = {
interval = 2;
"custom/currentplayer" = {
interval = 1;
return-type = "json";
exec = jsonOutput {
pre = ''player="$(${pkgs.preferredplayer}/bin/preferredplayer || echo No player set)"'';
pre = ''player="$(${playerctl} status -f "{{playerName}}" | cut -d '.' -f1)"'';
alt = "$player";
tooltip = "$player";
};
@@ -244,30 +262,23 @@ in
"qutebrowser" = "";
"discord" = "";
"sublimemusic" = "";
"No player set" = "";
"No players found" = "";
};
};
"custom/player" =
let
playerctl = "${pkgs.playerctl}/bin/playerctl";
preferredplayer = "${pkgs.preferredplayer}/bin/preferredplayer";
in
{
exec-if = ''
[[ "$(player=$(${preferredplayer}) && ${playerctl} --player $player status)" != "Stopped" ]]'';
exec = ''
player=$(${preferredplayer}) && ${playerctl} --player $player metadata --format '{"text": "{{artist}} - {{title}}", "alt": "{{status}}", "tooltip": "{{title}} ({{artist}} - {{album}})"}';
'';
return-type = "json";
interval = 2;
max-length = 30;
format = "{icon} {}";
format-icons = {
"Playing" = "";
"Paused" = "";
"Stopped" = "";
};
"custom/player" = {
exec-if = ''
[[ "$(${playerctl} status)" != "No players found" ]]'';
exec = ''${playerctl} metadata --format '{"text": "{{artist}} - {{title}}", "alt": "{{status}}", "tooltip": "{{title}} ({{artist}} - {{album}})"}' '';
return-type = "json";
interval = 1;
max-length = 30;
format = "{icon} {}";
format-icons = {
"Playing" = "";
"Paused" = "";
"Stopped" = "";
};
};
}];
# Cheatsheet:
# x -> all sides
+71 -25
View File
@@ -10,6 +10,8 @@
mako
primary-xwayland
sway-contrib.grimshot
pulseaudio
light
swaybg
swayidle
swaylock-effects
@@ -42,7 +44,7 @@
}
decoration {
active_opacity=0.95
active_opacity=0.96
inactive_opacity=0.8
fullscreen_opacity=1.0
rounding=3
@@ -68,14 +70,16 @@
kb_layout=br
}
exec=dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
# Startup
exec=dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY
exec-once=swaylock -i ${config.wallpaper}
exec-once=waybar
exec=swaybg -i ${config.wallpaper}
exec-once=mako
exec-once=swayidle -w
exec-once=systemctl --user start hyprland-session.target
# Program bindings
bind=SUPER,Return,exec,${terminal.cmd}
bind=SUPER,w,exec,${notifier.dismiss-cmd}
bind=SUPER,v,exec,${editor.cmd}
@@ -84,14 +88,14 @@
bind=SUPER,x,exec,${menu.drun-cmd}
bind=SUPER,d,exec,${menu.run-cmd}
# Pass menu
bind=,Scroll_Lock,exec,${menu.password-cmd} # fn+k
bind=,XF86Calculator,exec,${menu.password-cmd} # fn+f12
# Lock screen
bind=,XF86Launch5,exec,swaylock -S
bind=,XF86Launch4,exec,swaylock -S
# Screenshots
bind=,Print,exec,grimshot --notify copy output
bind=SHIFT,Print,exec,grimshot --notify copy active
bind=CONTROL,Print,exec,grimshot --notify copy screen
@@ -99,25 +103,38 @@
bind=SUPERSHIFT,S,exec,grimshot --notify copy area # fn+print on pleione
bind=SUPER,Print,exec,grimshot --notify copy window
# Keyboard controls (brightness, media, sound, etc)
bind=,XF86MonBrightnessUp,exec,light -A 10
bind=,XF86MonBrightnessDown,exec,light -U 10
bind=SUPER,f,fullscreen,0
bind=,XF86AudioNext,exec,playerctl next
bind=,XF86AudioPrev,exec,playerctl previous
bind=,XF86AudioPlay,exec,playerctl play-pause
bind=,XF86AudioStop,exec,playerctl stop
bind=,XF86AudioRaiseVolume,exec,pactl set-sink-volume @DEFAULT_SINK@ +5%
bind=,XF86AudioLowerVolume,exec,pactl set-sink-volume @DEFAULT_SINK@ -5%
bind=,XF86AudioMute,exec,pactl set-sink-mute @DEFAULT_SINK@ toggle
bind=SHIFT,XF86AudioMute,exec,pactl set-source-mute @DEFAULT_SOURCE@ toggle
bind=,XF86AudioMicMute,exec,pactl set-source-mute @DEFAULT_SOURCE@ toggle
# Window manager controls
bind=SUPERSHIFT,Q,killactive
bind=SUPERSHIFT,E,exit
bind=SUPER,s,togglesplit
bind=SUPER,f,fullscreen,0
bind=SUPERSHIFT,space,togglefloating
bind=SUPERALT,left,movecurrentworkspacetomonitor,l
bind=SUPERALT,right,movecurrentworkspacetomonitor,r
bind=SUPERALT,up,movecurrentworkspacetomonitor,u
bind=SUPERALT,down,movecurrentworkspacetomonitor,d
bind=SUPERALT,h,movecurrentworkspacetomonitor,l
bind=SUPERALT,l,movecurrentworkspacetomonitor,r
bind=SUPERALT,k,movecurrentworkspacetomonitor,u
bind=SUPERALT,j,movecurrentworkspacetomonitor,d
bind=SUPER,minus,splitratio,-0.25
bind=SUPERSHIFT,underscore,splitratio,-0.5
bind=SUPERCONTROL,minus,splitratio,-0.3333333
bind=SUPER,equal,splitratio,0.25
bind=SUPERSHIFT,plus,splitratio,0.5
bind=SUPERCONTROL,equal,splitratio,0.3333333
bind=SUPER,left,movefocus,l
bind=SUPER,right,movefocus,r
@@ -137,6 +154,18 @@
bind=SUPERSHIFT,k,movewindow,u
bind=SUPERSHIFT,j,movewindow,d
bind=SUPERALT,left,movecurrentworkspacetomonitor,l
bind=SUPERALT,right,movecurrentworkspacetomonitor,r
bind=SUPERALT,up,movecurrentworkspacetomonitor,u
bind=SUPERALT,down,movecurrentworkspacetomonitor,d
bind=SUPERALT,h,movecurrentworkspacetomonitor,l
bind=SUPERALT,l,movecurrentworkspacetomonitor,r
bind=SUPERALT,k,movecurrentworkspacetomonitor,u
bind=SUPERALT,j,movecurrentworkspacetomonitor,d
bind=SUPER,u,togglespecialworkspace
bind=SUPERSHIFT,u,movetoworkspace,special
bind=SUPER,1,workspace,1
bind=SUPER,2,workspace,2
bind=SUPER,3,workspace,3
@@ -148,16 +177,16 @@
bind=SUPER,9,workspace,9
bind=SUPER,0,workspace,10
bind=SUPERSHIFT,exclam,movetoworkspacesilent,1
bind=SUPERSHIFT,at,movetoworkspacesilent,2
bind=SUPERSHIFT,numbersign,movetoworkspacesilent,3
bind=SUPERSHIFT,dollar,movetoworkspacesilent,4
bind=SUPERSHIFT,percent,movetoworkspacesilent,5
bind=SUPERSHIFT,asciicircum,movetoworkspacesilent,6
bind=SUPERSHIFT,ampersand,movetoworkspacesilent,7
bind=SUPERSHIFT,asterisk,movetoworkspacesilent,8
bind=SUPERSHIFT,parenleft,movetoworkspacesilent,9
bind=SUPERSHIFT,parenright,movetoworkspacesilent,10
bind=SUPERSHIFT,exclam,movetoworkspace,1
bind=SUPERSHIFT,at,movetoworkspace,2
bind=SUPERSHIFT,numbersign,movetoworkspace,3
bind=SUPERSHIFT,dollar,movetoworkspace,4
bind=SUPERSHIFT,percent,movetoworkspace,5
bind=SUPERSHIFT,asciicircum,movetoworkspace,6
bind=SUPERSHIFT,ampersand,movetoworkspace,7
bind=SUPERSHIFT,asterisk,movetoworkspace,8
bind=SUPERSHIFT,parenleft,movetoworkspace,9
bind=SUPERSHIFT,parenright,movetoworkspace,10
'';
# Start automatically on tty1
@@ -176,4 +205,21 @@
exec Hyprland &> hyprland.log
fi
'';
systemd.user.targets.hyprland-session = {
Unit = {
Description = "hyprland compositor session";
Documentation = [ "man:systemd.special(7)" ];
BindsTo = [ "graphical-session.target" ];
Wants = [ "graphical-session-pre.target" ];
After = [ "graphical-session-pre.target" ];
};
};
systemd.user.targets.tray = {
Unit = {
Description = "Home Manager System Tray";
Requires = [ "graphical-session-pre.target" ];
};
};
}
+8 -20
View File
@@ -14,7 +14,6 @@ in
home.packages = with pkgs; [
light
playerctl
preferredplayer
primary-xwayland
pulseaudio # pactl
sway-contrib.grimshot
@@ -193,32 +192,21 @@ in
"XF86Launch4" = "exec swaylock -S"; # fn+q
# Volume
"XF86AudioRaiseVolume" =
"exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" =
"exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"XF86AudioRaiseVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"XF86AudioMute" = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
"Shift+XF86AudioMute" =
"exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86AudioMicMute" =
"exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"Shift+XF86AudioMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86AudioMicMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
# Brightness
"XF86MonBrightnessUp" = "exec light -A 10";
"XF86MonBrightnessDown" = "exec light -U 10";
# Media
"XF86AudioNext" =
"exec player=$(preferredplayer) && playerctl next --player $player";
"XF86AudioPrev" =
"exec player=$(preferredplayer) && playerctl previous --player $player";
"XF86AudioPlay" =
"exec player=$(preferredplayer) && playerctl play-pause --player $player";
"XF86AudioStop" =
"exec player=$(preferredplayer) && playerctl stop --player $player";
"Shift+XF86AudioPlay" =
"exec player=$(playerctl -l | ${menu.dmenu-cmd}) && preferredplayer $player";
"Shift+XF86AudioStop" = "exec preferredplayer none";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioStop" = "exec playerctl stop";
# Notifications
"${modifier}+w" = "exec ${notifier.dismiss-cmd}";
+1 -3
View File
@@ -4,10 +4,8 @@ in {
services.rgbdaemon = {
enable = true;
daemons = {
swayWorkspaces = true;
swayLock = true;
mute = true;
tty = true;
player = true;
};
colors = {
@@ -19,7 +17,7 @@ in {
};
keyboard = {
device = "/dev/input/ckb1/cmd";
highlighted = [ "h" "j" "k" "l" "w" "a" "s" "d" "m3" "g11" "profswitch" ];
highlighted = [ "h" "j" "k" "l" "w" "a" "s" "d" "m3" "g11" "profswitch" "lwin" "rwin" ];
};
mouse = {
device = "/dev/input/ckb2/cmd";
+1 -1
View File
@@ -39,7 +39,7 @@ let
, system ? getSystemKind hostname
, packages
, persistence ? false
, colorscheme ? "nord"
, colorscheme ? null
, wallpaper ? null
, desktop ? null
, features ? [ ]
+4 -3
View File
@@ -107,11 +107,12 @@ in
config = mkIf cfg.enable {
systemd.user.services.afuse = {
Unit.Description = "afuse automatic FUSE mounter";
Unit = {
Description = "afuse automatic FUSE mounter";
After = [ "network.target" ];
};
Install.WantedBy = [ "default.target" ];
Service = {
After = [ "network.target" ];
# Make sure mountpoint exists
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${cfg.mountpoint}";
ExecStart = replaceStrings ["%"] ["%%"] # Extra percent for escaping
"${cfg.package}/bin/afuse ${optionalString cfg.debug "-d"} ${cfg.mountpoint} ${afuseArguments.generate null cfg.settings} -f";
+1 -17
View File
@@ -23,13 +23,6 @@ in {
'';
};
daemons = {
swayWorkspaces = mkOption {
type = types.bool;
default = false;
description = ''
Enable sway workspaces daemon
'';
};
mute = mkOption {
type = types.bool;
default = false;
@@ -37,13 +30,6 @@ in {
Enable mute button daemon
'';
};
tty = mkOption {
type = types.bool;
default = false;
description = ''
Enable tty status daemon
'';
};
swayLock = mkOption {
type = types.bool;
default = false;
@@ -121,10 +107,8 @@ in {
COLOR_SECONDARY=${cfg.colors.secondary}
COLOR_TERTIARY=${cfg.colors.tertiary}
COLOR_QUATERNARY=${cfg.colors.quaternary}
ENABLE_SWAY_WORKSPACES=${toString cfg.daemons.swayWorkspaces}
ENABLE_SWAY_LOCK=${toString cfg.daemons.swayLock}
ENABLE_MUTE=${toString cfg.daemons.mute}
ENABLE_TTY=${toString cfg.daemons.tty}
ENABLE_PLAYER=${toString cfg.daemons.player}
'';
onChange = ''
@@ -138,7 +122,7 @@ in {
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
Restart = "on-failure";
};
Install = { WantedBy = [ "sway-session.target" ]; };
Install = { WantedBy = [ "graphical-session.target" ]; };
};
};
}
+12
View File
@@ -42,6 +42,18 @@ in
mesonFlags = oldAttrs.mesonFlags ++ [ "-Dexperimental=true" ];
});
# Temporary fix for https://github.com/emersion/xdg-desktop-portal-wlr/issues/216
xdg-desktop-portal-wlr = prev.xdg-desktop-portal-wlr.overrideAttrs (oldAttrs: rec {
pname = "xdg-desktop-portal-wlr";
version = "0.5.0";
src = prev.fetchFromGitHub {
owner = "emersion";
repo = pname;
rev = "v${version}";
sha256 = "sha256-weePlNcLmZ3R0IDQ95p0wQvsKTYp+sVlTENJtF8Z78Y";
};
});
generated-gtk-themes = mapAttrs (_: scheme: gtkThemeFromScheme { inherit scheme; }) colorSchemes;
} // import ../pkgs { pkgs = prev; }
-1
View File
@@ -14,7 +14,6 @@
# Personal scripts
minicava = pkgs.callPackage ./minicava { };
pass-wofi = pkgs.callPackage ./pass-wofi { };
preferredplayer = pkgs.callPackage ./preferredplayer { };
primary-xwayland = pkgs.callPackage ./primary-xwayland { };
wl-mirror-pick = pkgs.callPackage ./wl-mirror-pick { };
}
+13 -4
View File
@@ -1,5 +1,16 @@
{ lib, stdenv, fetchFromGitHub, makeWrapper, pass, jq, wofi, libnotify
, qutebrowser, sway, wl-clipboard, findutils, gnused, coreutils }:
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, pass
, jq
, wofi
, libnotify
, wl-clipboard
, findutils
, gnused
, coreutils
}:
with lib;
@@ -27,8 +38,6 @@ stdenv.mkDerivation {
jq
wofi
libnotify
qutebrowser
sway
wl-clipboard
findutils
gnused
-31
View File
@@ -1,31 +0,0 @@
{ lib, stdenv, writeShellScriptBin, playerctl, procps, pkgs, clematis ? pkgs.callPackage ../clematis { } }:
with lib;
stdenv.mkDerivation {
name = "preferredplayer";
version = "1.0";
src = writeShellScriptBin "preferredplayer" ''
if [[ -z "$1" ]]; then
players=$(${playerctl}/bin/playerctl --list-all 2>/dev/null | \
grep "$(cat $XDG_RUNTIME_DIR/currentplayer 2> /dev/null || echo '.*')") && \
echo "$players" | head -1
else
echo "$1" > $XDG_RUNTIME_DIR/currentplayer
${procps}/bin/pkill clematis
${clematis}/bin/clematis -c <( echo "{\"whitelist\": [\"$1\"]}") & disown
fi
'';
dontBuild = true;
dontConfigure = true;
installPhase =
"install -Dm 0755 $src/bin/preferredplayer $out/bin/preferredplayer";
meta = {
description = "A script for setting a preferred player";
license = licenses.mit;
platforms = platforms.all;
maintainers = with maintainers; [ misterio77 ];
};
}
+147 -43
View File
@@ -1,7 +1,5 @@
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, writeShellApplication
, findutils
, gnugrep
, procps
@@ -11,53 +9,159 @@
, pastel
, pulseaudio
, playerctl
, sway
, pkgs
, preferredplayer ? pkgs.callPackage ../preferredplayer { }
}:
with lib;
stdenv.mkDerivation {
writeShellApplication {
name = "rgbdaemon";
version = "0.1";
src = fetchFromGitHub {
owner = "Misterio77";
repo = "rgbdaemon";
rev = "068dcad606267a84f15c3decabaaac835feac2d1";
sha256 = "sha256-Ek0MaUR0SO+zWukdXhKto/bWtN/Yd7CO/MoXzHj+E0A=";
};
runtimeInputs = [
findutils
gnugrep
procps
gawk
coreutils
openrgb
pastel
pulseaudio
playerctl
];
nativeBuildInputs = [ makeWrapper ];
checkPhase = "";
text = /* bash */ ''
set +o errexit
set +o nounset
set +o pipefail
dontBuild = true;
dontConfigure = true;
base_colors() {
echo "rgb $1" > $KEYBOARD_DEVICE
echo "rgb $1" > $MOUSE_DEVICE
echo "rgb $KEYBOARD_HIGHLIGHTED:$2" > $KEYBOARD_DEVICE
echo "rgb $MOUSE_HIGHLIGHTED:$2" > $MOUSE_DEVICE
}
installPhase = ''
install -Dm 0755 rgbdaemon.sh $out/bin/rgbdaemon
wrapProgram $out/bin/rgbdaemon --set PATH \
"${
makeBinPath [
findutils
gnugrep
procps
gawk
coreutils
openrgb
pastel
pulseaudio
playerctl
preferredplayer
sway
]
}"
setcolor() {
echo "rgb $1:$2" > $3
}
daemon_mute() {
audio_input=$(pactl info | grep "Default Source" | cut -f3 -d " ")
audio_output=$(pactl info | grep "Default Sink" | cut -f3 -d " ")
input_muted=$(pactl list sources | grep -A 10 "''${audio_input}" | grep "Mute" | cut -d ":" -f2 | xargs)
output_muted=$(pactl list sinks | grep -A 10 "''${audio_output}" | grep "Mute" | cut -d ":" -f2 | xargs)
if [[ "$output_muted" == "yes" ]] && [[ "$input_muted" == "yes" ]]; then
setcolor "mute" "$4" $KEYBOARD_DEVICE
elif [[ "$input_muted" == "yes" ]]; then
setcolor "mute" $3 $KEYBOARD_DEVICE
elif [[ "$output_muted" == "yes" ]]; then
setcolor "mute" $2 $KEYBOARD_DEVICE
else
setcolor "mute" $1 $KEYBOARD_DEVICE
fi
}
daemon_player() {
status=$(playerctl status 2>/dev/null | head -n 1)
if [[ $status == "Playing" ]]; then
setcolor "play" $1 $KEYBOARD_DEVICE
elif [[ $status == "Paused" ]]; then
setcolor "play" $2 $KEYBOARD_DEVICE
else
setcolor "play" $3 $KEYBOARD_DEVICE
fi
}
daemon_lock() {
if pgrep -x swaylock > /dev/null; then
setcolor "lock" $1 $KEYBOARD_DEVICE
else
setcolor "lock" $2 $KEYBOARD_DEVICE
fi
}
bindings() {
echo "bind profswitch:f13" > $KEYBOARD_DEVICE
echo "bind lock:f14" > $KEYBOARD_DEVICE
echo "bind light:f15" > $KEYBOARD_DEVICE
echo "bind thumb1:1" > $MOUSE_DEVICE
echo "bind thumb2:2" > $MOUSE_DEVICE
echo "bind thumb3:3" > $MOUSE_DEVICE
echo "bind thumb4:4" > $MOUSE_DEVICE
echo "bind thumb5:5" > $MOUSE_DEVICE
echo "bind thumb6:6" > $MOUSE_DEVICE
echo "bind thumb7:7" > $MOUSE_DEVICE
echo "bind thumb8:8" > $MOUSE_DEVICE
echo "bind thumb9:9" > $MOUSE_DEVICE
echo "bind thumb10:0" > $MOUSE_DEVICE
echo "bind thumb11:minus" > $MOUSE_DEVICE
echo "bind thumb12:equal" > $MOUSE_DEVICE
echo "bind dpiup:mouse4" > $MOUSE_DEVICE
echo "bind dpidn:mouse5" > $MOUSE_DEVICE
}
startup() {
if [ -n "''${rgb_pid}" ]; then
kill "''${rgb_pid}"
fi
source ''${XDG_CONFIG_HOME:-$HOME/.config}/rgbdaemon.conf
export DAEMON_INTERVAL=''${DAEMON_INTERVAL:-0.8}
export KEYBOARD_DEVICE=''${KEYBOARD_DEVICE:-/dev/input/ckb1/cmd}
export MOUSE_DEVICE=''${MOUSE_DEVICE:-/dev/input/ckb2/cmd}
export KEYBOARD_HIGHLIGHTED=''${KEYBOARD_HIGHLIGHTED}
export MOUSE_HIGHLIGHTED=''${MOUSE_HIGHLIGHTED}
export ENABLE_SWAY_WORKSPACES=''${ENABLE_SWAY_WORKSPACES}
export ENABLE_SWAY_LOCK=''${ENABLE_SWAY_LOCK}
export ENABLE_MUTE=''${ENABLE_MUTE}
export ENABLE_TTY=''${ENABLE_TTY}
export ENABLE_PLAYER=''${ENABLE_PLAYER}
export color_primary=$(pastel mix $COLOR_BACKGROUND --fraction 0.7 $COLOR_FOREGROUND | pastel darken 0.1 | pastel saturate 0.5 | pastel format hex | cut -d '#' -f2)
export color_secondary=$(pastel darken 0.1 $COLOR_SECONDARY | pastel saturate 0.8 | pastel format hex | cut -d '#' -f2)
export color_tertiary=$(pastel saturate 0.1 $COLOR_TERTIARY | pastel format hex | cut -d '#' -f2)
export color_quaternary=$(pastel lighten 0.1 $COLOR_QUATERNARY | pastel format hex | cut -d '#' -f2)
echo "COLORS: $color_primary | $color_secondary | $color_tertiary | $color_quaternary"
# Activate devices
echo active > $KEYBOARD_DEVICE || exit -1
echo active > $MOUSE_DEVICE || exit -1
echo "dpi 1:$MOUSE_DPI dpisel 1" > $MOUSE_DEVICE
# Set up bindings
bindings
base_colors $color_primary $color_secondary & \
openrgb --client --color $color_primary --mode static & \
rgb_daemon & rgb_pid=$!
wait
}
off() {
echo "rgb 000000" > $MOUSE_DEVICE & \
echo "rgb 000000" > $KEYBOARD_DEVICE
openrgb --client --color "000000" --mode static
exit
}
rgb_daemon() {
while sleep $DAEMON_INTERVAL; do
[[ "$ENABLE_SWAY_LOCK" == 1 ]] && \
daemon_lock $color_secondary $color_primary & \
[[ "$ENABLE_MUTE" == 1 ]] && \
daemon_mute "000000" $color_primary $color_tertiary $color_secondary & \
[[ "$ENABLE_PLAYER" == 1 ]] && \
daemon_player $color_secondary $color_tertiary $color_primary & \
done
}
trap startup SIGHUP
trap off SIGTERM
startup
'';
meta = {
description = "A daemon that interacts with ckb-next and openrgb";
homepage = "https://github.com/Misterio77/rgbdaemon";
license = licenses.mit;
platforms = platforms.all;
maintainers = with maintainers; [ misterio77 ];
};
}
+1 -1
View File
@@ -17,7 +17,7 @@ function fetch_image() {
echo " }"
}
album="bXDPRpV"
album="bXDPRpV" # https://imgur.com/a/bXDPRpV
clientid="0c2b2b57cdbe5d8"
result=$(https api.imgur.com/3/album/$album Authorization:"Client-ID $clientid")