Try out river as a compositor
This commit is contained in:
parent
d1cb0d8a4d
commit
b0f4c448f6
10 changed files with 411 additions and 432 deletions
7
modules/graphical/compositor/color-picker.nix
Normal file
7
modules/graphical/compositor/color-picker.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellScriptBin "color_picker" ''
|
||||
color=$(${pkgs.grim}/bin/grim -t png -g "$(${pkgs.slurp}/bin/slurp -p)" - | ${pkgs.imagemagick}/bin/convert png:- -unique-colors txt:- | grep -o '#[A-F0-9]\+')
|
||||
|
||||
${pkgs.sway}/bin/swaymsg exec -- "echo -n '$color' | ${pkgs.wl-clipboard}/bin/wl-copy --foreground"
|
||||
''
|
321
modules/graphical/compositor/default.nix
Normal file
321
modules/graphical/compositor/default.nix
Normal file
|
@ -0,0 +1,321 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
launcher = import ./launcher.nix { inherit pkgs; stdenv = pkgs.stdenv; };
|
||||
color-picker = import ./color-picker.nix { inherit pkgs; };
|
||||
screenshot = import ./screenshot.nix { inherit pkgs; };
|
||||
mic-status = pkgs.writeShellScript "mic-status" ''
|
||||
if [ "$(${pkgs.pulseaudio}/bin/pactl list sources | grep -o 'Mute: yes')" = "Mute: yes" ]
|
||||
then
|
||||
echo -e '\uf131'
|
||||
else
|
||||
echo -e '\uf130'
|
||||
fi
|
||||
'';
|
||||
mail-status = pkgs.writeShellScript "mail-status" ''
|
||||
mails=$(${pkgs.mblaze}/bin/mlist -N ~/mail/*/INBOX | wc -l)
|
||||
if [ "$mails" -gt 0 ]
|
||||
then
|
||||
echo "{ \"state\": \"Info\", \"text\": \"📬 $mails\" }"
|
||||
else
|
||||
echo "{ \"state\": \"Idle\", \"text\": \"📭\" }"
|
||||
fi
|
||||
'';
|
||||
river-init = pkgs.writeShellScript "river-init" ''
|
||||
riverctl map normal Super Return spawn footclient
|
||||
riverctl map normal Super D spawn 'footclient --app-id launcher -- ${launcher}/bin/launcher'
|
||||
|
||||
riverctl map normal Super C spawn ${pkgs.swaylock}/bin/swaylock
|
||||
|
||||
riverctl map normal Super+Shift C close
|
||||
|
||||
riverctl map normal Super+Shift E exit
|
||||
|
||||
riverctl map normal Super J focus-view next
|
||||
riverctl map normal Super K focus-view previous
|
||||
|
||||
riverctl map normal Super+Shift J swap next
|
||||
riverctl map normal Super+Shift K swap previous
|
||||
|
||||
riverctl map normal Super H focus-output next
|
||||
riverctl map normal Super L focus-output previous
|
||||
|
||||
riverctl map normal Super+Shift H send-to-output next
|
||||
riverctl map normal Super+Shift L send-to-output previous
|
||||
|
||||
riverctl map normal Super F zoom
|
||||
riverctl map normal Super+Shift F toggle-fullscreen
|
||||
|
||||
riverctl map normal Super+Control H send-layout-cmd rivertile "main-ratio -0.05"
|
||||
riverctl map normal Super+Control L send-layout-cmd rivertile "main-ratio +0.05"
|
||||
|
||||
riverctl map normal Super+Control+Shift H send-layout-cmd rivertile "main-count +1"
|
||||
riverctl map normal Super+Control+Shift L send-layout-cmd rivertile "main-count -1"
|
||||
|
||||
riverctl map normal Super+Alt H move left 100
|
||||
riverctl map normal Super+Alt J move down 100
|
||||
riverctl map normal Super+Alt K move up 100
|
||||
riverctl map normal Super+Alt L move right 100
|
||||
|
||||
riverctl map normal Super+Alt+Control H snap left
|
||||
riverctl map normal Super+Alt+Control J snap down
|
||||
riverctl map normal Super+Alt+Control K snap up
|
||||
riverctl map normal Super+Alt+Control L snap right
|
||||
|
||||
riverctl map normal Super+Alt+Shift H resize horizontal -100
|
||||
riverctl map normal Super+Alt+Shift J resize vertical 100
|
||||
riverctl map normal Super+Alt+Shift K resize vertical -100
|
||||
riverctl map normal Super+Alt+Shift L resize horizontal 100
|
||||
|
||||
riverctl map normal Super Space toggle-float
|
||||
|
||||
riverctl map-pointer normal Super BTN_LEFT move-view
|
||||
riverctl map-pointer normal Super BTN_RIGHT resize-view
|
||||
|
||||
for i in $(seq 1 9)
|
||||
do
|
||||
tags=$((1 << ($i - 1)))
|
||||
riverctl map normal Super $i set-focused-tags $tags
|
||||
riverctl map normal Super+Shift $i set-view-tags $tags
|
||||
riverctl map normal Super+Control $i toggle-focused-tags $tags
|
||||
riverctl map normal Super+Shift+Control $i toggle-view-tags $tags
|
||||
done
|
||||
|
||||
all_tags=$(((1 << 32) - 1))
|
||||
riverctl map normal Super 0 set-focused-tags $all_tags
|
||||
riverctl map normal Super+Shift 0 set-view-tags $all_tags
|
||||
|
||||
riverctl map normal Super Up send-layout-cmd rivertile "main-location top"
|
||||
riverctl map normal Super Right send-layout-cmd rivertile "main-location right"
|
||||
riverctl map normal Super Down send-layout-cmd rivertile "main-location bottom"
|
||||
riverctl map normal Super Left send-layout-cmd rivertile "main-location left"
|
||||
|
||||
riverctl map normal None XF86AudioRaiseVolume spawn '${pkgs.pamixer}/bin/pamixer -i 5'
|
||||
riverctl map normal None XF86AudioLowerVolume spawn '${pkgs.pamixer}/bin/pamixer -d 5'
|
||||
riverctl map normal None XF86AudioMute spawn '${pkgs.pamixer}/bin/pamixer --toggle-mute'
|
||||
|
||||
riverctl float-filter-add app-id launcher
|
||||
riverctl float-filter-add app-id be.ugent.dominion.Main
|
||||
riverctl float-filter-add title "Quick Format Citation"
|
||||
|
||||
riverctl default-layout rivertile
|
||||
rivertile -view-padding 0 -outer-padding 0 &
|
||||
|
||||
riverctl attach-mode bottom
|
||||
riverctl background-color 0x000000
|
||||
riverctl border-color-focused 0x6aaeff
|
||||
riverctl border-color-unfocused 0xf2eff3
|
||||
riverctl border-color-urgent 0xff8892
|
||||
riverctl border-width 2
|
||||
riverctl focus-follows-cursor normal
|
||||
riverctl hide-cursor when-typing enabled
|
||||
riverctl set-cursor-warp on-output-change
|
||||
riverctl xcursor-theme Vanilla-DMZ
|
||||
|
||||
riverctl keyboard-layout -variant altgr-intl -options compose:caps us
|
||||
|
||||
configure_touchpads() {
|
||||
riverctl list-inputs | grep 'type: pointer' -B 1 | grep -vE 'type: pointer|^--$' | xargs -I '{}' riverctl input '{}' $@
|
||||
}
|
||||
|
||||
configure_touchpads drag enabled
|
||||
configure_touchpads tap enabled
|
||||
configure_touchpads scroll-method two-finger
|
||||
|
||||
${pkgs.dbus}/bin/dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE
|
||||
systemctl --user start graphical-session.target
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.chvp.graphical.compositor.enable = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
|
||||
config = lib.mkIf config.chvp.graphical.compositor.enable {
|
||||
services = {
|
||||
dbus.packages = with pkgs; [ dconf ];
|
||||
greetd = {
|
||||
enable = true;
|
||||
settings =
|
||||
let
|
||||
wrapped-command = pkgs.writeShellScript "river-run" ''
|
||||
export XDG_SESSION_TYPE=wayland
|
||||
export XDG_CURRENT_DESKTOP=river
|
||||
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
|
||||
export QT_AUTO_SCREEN_SCALE_FACTOR=0
|
||||
export QT_SCALE_FACTOR=1
|
||||
export GDK_SCALE=1
|
||||
export GDK_DPI_SCALE=1
|
||||
export MOZ_ENABLE_WAYLAND=1
|
||||
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||
zsh -c "${pkgs.dbus}/bin/dbus-run-session river"
|
||||
'';
|
||||
in
|
||||
{
|
||||
default_session = {
|
||||
command = "${pkgs.greetd.greetd}/bin/agreety --cmd ${wrapped-command}";
|
||||
};
|
||||
initial_session = {
|
||||
command = "${wrapped-command}";
|
||||
user = "charlotte";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
security.pam.services.swaylock = { };
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
extraPortals = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr ];
|
||||
};
|
||||
home-manager.users.charlotte = { pkgs, ... }: {
|
||||
home.packages = with pkgs; [
|
||||
river
|
||||
color-picker
|
||||
screenshot
|
||||
wf-recorder
|
||||
wl-clipboard
|
||||
];
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
settings = {
|
||||
mainBar = {
|
||||
spacing = 2;
|
||||
modules-left = [ "river/tags" ];
|
||||
modules-center = [ "river/window" ];
|
||||
modules-right = [ "idle_inhibitor" "network" "pulseaudio" "mpris" "backlight" "battery" "clock" "tray" ];
|
||||
backlight = {
|
||||
format = "{percent}%";
|
||||
};
|
||||
battery = {
|
||||
states = {
|
||||
good = 95;
|
||||
warning = 30;
|
||||
critical = 15;
|
||||
};
|
||||
format = "{capacity}% {icon}";
|
||||
format-charging = "{capacity}% ";
|
||||
format-plugged = "{capacity}% ";
|
||||
format-alt = "{time} {icon}";
|
||||
format-icons = [ "" "" "" "" "" ];
|
||||
};
|
||||
idle_inhibitor = {
|
||||
format = "{icon}";
|
||||
format-icons = {
|
||||
activated = "";
|
||||
deactivated = "";
|
||||
};
|
||||
};
|
||||
mpris.player = "firefox";
|
||||
network = {
|
||||
format-wifi = "{essid} ({signalStrength}%) ";
|
||||
format-ethernet = "{ipaddr}/{cidr} ";
|
||||
tooltip-format = "{ifname} via {gwaddr} ";
|
||||
format-linked = "{ifname} (No IP) ";
|
||||
format-disconnected = "Disconnected ⚠";
|
||||
format-alt = "{ifname}: {ipaddr}/{cidr}";
|
||||
};
|
||||
pulseaudio = {
|
||||
format = "{volume}% {icon} {format_source}";
|
||||
format-bluetooth = "{volume}% {icon} {format_source}";
|
||||
format-bluetooth-muted = " {icon} {format_source}";
|
||||
format-muted = " {format_source}";
|
||||
format-source = "{volume}% ";
|
||||
format-source-muted = "";
|
||||
format-icons = {
|
||||
headphone = "";
|
||||
hands-free = "";
|
||||
headset = "";
|
||||
phone = "";
|
||||
portable = "";
|
||||
car = "";
|
||||
default = [ "" "" "" ];
|
||||
};
|
||||
on-click = "pavucontrol";
|
||||
};
|
||||
tray.spacing = 2;
|
||||
};
|
||||
};
|
||||
style = ''
|
||||
* {
|
||||
font-family: Hack, monospace;
|
||||
font-size: 11px;
|
||||
}
|
||||
window#waybar {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
#tags button {
|
||||
border-radius: 0;
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
#tags button.occupied {
|
||||
background-color: #f2eff3;
|
||||
}
|
||||
#tags button.focused {
|
||||
background-color: #6aaeff;
|
||||
}
|
||||
#tags button.urgent {
|
||||
background-color: #ff8892;
|
||||
}
|
||||
'';
|
||||
systemd.enable = true;
|
||||
};
|
||||
services = {
|
||||
kanshi = {
|
||||
enable = true;
|
||||
systemdTarget = "graphical-session.target";
|
||||
profiles = {
|
||||
"home-undocked" = {
|
||||
outputs = [
|
||||
{ criteria = "AU Optronics 0x2036 Unknown"; position = "0,0"; mode = "2560x1440"; scale = 1.0; }
|
||||
];
|
||||
};
|
||||
"home-docked" = {
|
||||
outputs = [
|
||||
{ criteria = "AU Optronics 0x2036 Unknown"; position = "0,0"; mode = "2560x1440"; scale = 1.0; }
|
||||
{ criteria = "Dell Inc. DELL U2718Q FN84K01T095L"; position = "2560,0"; mode = "3840x2160"; scale = 1.0; }
|
||||
];
|
||||
};
|
||||
"work-undocked" = {
|
||||
outputs = [
|
||||
{ criteria = "LG Display 0x06D6 Unknown"; position = "0,0"; mode = "1920x1080"; scale = 1.0; }
|
||||
];
|
||||
};
|
||||
"work-docked" = {
|
||||
outputs = [
|
||||
{ criteria = "LG Display 0x06D6 Unknown"; position = "0,0"; mode = "1920x1080"; scale = 1.0; }
|
||||
{ criteria = "Dell Inc. DELL U2718Q FN84K83Q1KHL"; position = "1920,0"; mode = "3840x2160"; scale = 1.0; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
mako = {
|
||||
enable = true;
|
||||
font = "Hack Regular 9";
|
||||
};
|
||||
swayidle = {
|
||||
enable = true;
|
||||
systemdTarget = "graphical-session.target";
|
||||
events = [{ event = "before-sleep"; command = "${pkgs.swaylock}/bin/swaylock"; }];
|
||||
timeouts = [
|
||||
{ timeout = 150; command = "${pkgs.wlopm}/bin/wlopm --off '*'"; resumeCommand = "${pkgs.wlopm}/bin/wlopm --on '*'"; }
|
||||
{ timeout = 300; command = "${pkgs.swaylock}/bin/swaylock -fF"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
xdg.configFile."river/init" = {
|
||||
source = river-init;
|
||||
onChange = ''
|
||||
WAYLAND_DISPLAY="$(${pkgs.findutils}/bin/find /run/user/$UID -mindepth 1 -maxdepth 1 -type s -name wayland-\*)"
|
||||
if [ -S "WAYLAND_DISPLAY" ]
|
||||
then
|
||||
${river-init}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
24
modules/graphical/compositor/launcher.nix
Normal file
24
modules/graphical/compositor/launcher.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ pkgs, stdenv }:
|
||||
let
|
||||
script = pkgs.substituteAll {
|
||||
src = ./launcher.zsh;
|
||||
inherit (pkgs)
|
||||
fzy
|
||||
jq
|
||||
libqalculate
|
||||
nix
|
||||
pass
|
||||
slurp
|
||||
uni
|
||||
zsh
|
||||
;
|
||||
wfRecorder = pkgs.wf-recorder;
|
||||
wlClipboard = pkgs.wl-clipboard;
|
||||
xdgUserDirs = pkgs.xdg-user-dirs;
|
||||
};
|
||||
in
|
||||
pkgs.runCommand "launcher" { } ''
|
||||
mkdir -p $out/bin
|
||||
cp ${script} $out/bin/launcher
|
||||
chmod +x $out/bin/launcher
|
||||
''
|
81
modules/graphical/compositor/launcher.zsh
Normal file
81
modules/graphical/compositor/launcher.zsh
Normal file
|
@ -0,0 +1,81 @@
|
|||
#!@zsh@/bin/zsh
|
||||
|
||||
_sighandler() {
|
||||
kill -INT "$child" 2>/dev/null
|
||||
}
|
||||
|
||||
calc_options() {
|
||||
echo "calc "
|
||||
}
|
||||
|
||||
calc() {
|
||||
if [ -n "$1" ]
|
||||
then
|
||||
@libqalculate@/bin/qalc "$1"
|
||||
sleep 5
|
||||
else
|
||||
@libqalculate@/bin/qalc
|
||||
fi
|
||||
}
|
||||
|
||||
emoji_options() {
|
||||
@uni@/bin/uni emoji all | sed "s/^/emoji /"
|
||||
}
|
||||
|
||||
emoji() {
|
||||
char=$(echo -n "$1" | sed "s/^\([^ ]*\) .*/\1/")
|
||||
riverctl spawn "echo -n $char | @wlClipboard@/bin/wl-copy --foreground"
|
||||
}
|
||||
|
||||
nrun_options() {
|
||||
echo "nrun "
|
||||
}
|
||||
|
||||
nrun() {
|
||||
riverctl spawn "@nix@/bin/nix run nixpkgs\#$1"
|
||||
}
|
||||
|
||||
pass_options(){
|
||||
prefix=${PASSWORD_STORE_DIR-~/.password-store}
|
||||
password_files=( "$prefix"/**/*.gpg )
|
||||
printf 'password %s\n' ${${password_files%.gpg}#$prefix/}
|
||||
printf 'username %s\n' ${${password_files%.gpg}#$prefix/}
|
||||
printf 'otp %s\n' ${${password_files%.gpg}#$prefix/}
|
||||
}
|
||||
|
||||
username() {
|
||||
riverctl spawn "@pass@/bin/pass show '$@' | sed -n 's/^Username: *//p' | tr -d '\n' | @wlClipboard@/bin/wl-copy --foreground"
|
||||
}
|
||||
|
||||
password() {
|
||||
riverctl spawn "@pass@/bin/pass show -c0 '$@'"
|
||||
}
|
||||
|
||||
otp() {
|
||||
riverctl spawn "@pass@/bin/pass otp -c '$@'"
|
||||
}
|
||||
|
||||
run_options() {
|
||||
print -rl -- ''${(ko)commands} | grep -v "^\\." | sed "s/^/run /"
|
||||
}
|
||||
|
||||
run() {
|
||||
riverctl spawn $1
|
||||
}
|
||||
|
||||
systemctl_options() {
|
||||
echo systemctl hibernate
|
||||
echo systemctl poweroff
|
||||
echo systemctl reboot
|
||||
echo systemctl suspend
|
||||
}
|
||||
|
||||
CHOSEN=$(cat <(systemctl_options) <(pass_options) <(nrun_options) <(run_options) <(calc_options) <(emoji_options) | @fzy@/bin/fzy --lines 80 | tail -n1)
|
||||
|
||||
if [ -n "$CHOSEN" ]
|
||||
then
|
||||
PREFIX=$(echo $CHOSEN | sed "s/^\([^ ]*\) .*/\1/g")
|
||||
WORD=$(echo $CHOSEN | sed "s/^[^ ]* \(.*\)/\1/g")
|
||||
|
||||
$PREFIX $WORD
|
||||
fi
|
36
modules/graphical/compositor/screenshot.nix
Normal file
36
modules/graphical/compositor/screenshot.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ pkgs }:
|
||||
|
||||
pkgs.writeShellScriptBin "screenshot" ''
|
||||
while getopts ":rd" opt
|
||||
do
|
||||
case "''${opt}" in
|
||||
r)
|
||||
remote=true
|
||||
;;
|
||||
d)
|
||||
delay=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
dims="$(${pkgs.slurp}/bin/slurp)"
|
||||
|
||||
if [[ -n "$delay" ]]
|
||||
then
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
if [[ -n "$remote" ]]
|
||||
then
|
||||
name=$(${pkgs.util-linux}/bin/uuidgen).png
|
||||
${pkgs.grim}/bin/grim -t png -g "$dims" - | ${pkgs.openssh}/bin/ssh data "cat > data/public/$name"
|
||||
path="https://data.vanpetegem.me/public/$name"
|
||||
else
|
||||
name=$(date +'screenshot_%Y-%m-%d-%H%M%S.png')
|
||||
path="$(${pkgs.xdg-user-dirs}/bin/xdg-user-dir PICTURES)/$name"
|
||||
${pkgs.grim}/bin/grim -g "$dims" "$path"
|
||||
fi
|
||||
|
||||
${pkgs.sway}/bin/swaymsg exec -- "echo -n '$path' | ${pkgs.wl-clipboard}/bin/wl-copy --foreground"
|
||||
${pkgs.libnotify}/bin/notify-send "Screenshot taken" "$path"
|
||||
''
|
Loading…
Add table
Add a link
Reference in a new issue