diff --git a/home.nix b/home.nix index a85b0b9..264d01c 100644 --- a/home.nix +++ b/home.nix @@ -7,6 +7,7 @@ in ./fish/settings.nix ./variables.nix ./i3/settings.nix + ./sway/settings.nix ./kitty/settings.nix ./rofi/settings.nix ./i3/i3status-rust.nix diff --git a/sway/__pycache__/audiotools.cpython-311.pyc b/sway/__pycache__/audiotools.cpython-311.pyc new file mode 100644 index 0000000..f6631ac Binary files /dev/null and b/sway/__pycache__/audiotools.cpython-311.pyc differ diff --git a/sway/audiotools.py b/sway/audiotools.py new file mode 100755 index 0000000..b8271f7 --- /dev/null +++ b/sway/audiotools.py @@ -0,0 +1,58 @@ +import subprocess + + +def show_now_playing(): + id = ["-r", "3984938"] + + try: + status = subprocess.Popen( + ["playerctl", "status"], + stdout=subprocess.PIPE, + ) + now_playing = subprocess.Popen( + [ + "playerctl", + "metadata", + "--format", + "{artist}\n\n{title}".format( + artist="🧑‍🎨 {{artist}}", + title="🎵 {{title}}", + ), + ], + stdout=subprocess.PIPE, + ) + + subprocess.run( + [ + "dunstify", + "⏯ {}".format(status.communicate()[0].decode()), + now_playing.communicate()[0], + ] + + id + ) + except: + subprocess.run(["dunstify", "⏯ ", "🦗 nothing to see here..."] + id) + + +def get_amixer_volume() -> int: + s: str = str(subprocess.check_output(["amixer", "get", "Master"])) + try: + # turns the front left argument into an int + return int( + # the thing we're looking for is in the fifth line + s.split(r"\n")[5] + .strip() + # and is the 4th word + .split(" ")[4] + .replace("[", "") + .replace("]", "") + .replace("%", "") + ) + except: + return -1 + + +def display_volume(volume: int): + subprocess.call( + ["dunstify", "volume 蓼", "-h", "int:value:" + str(volume), "-r", "39489384"] + ) diff --git a/sway/brightness.py b/sway/brightness.py new file mode 100755 index 0000000..53cc459 --- /dev/null +++ b/sway/brightness.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +import subprocess +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument("brightnesschange") +args = parser.parse_args() + + +def get_brightness() -> str: + return str( + ( + int( + subprocess.check_output( + ["cat", "/sys/class/backlight/intel_backlight/brightness"] + ) + ) + / int( + subprocess.check_output( + ["cat", "/sys/class/backlight/intel_backlight/max_brightness"] + ) + ) + * 100 + ).__round__() + ) + + +subprocess.check_output( + [ + "brightnessctl", + "set", + args.brightnesschange, + ] +) + +print(get_brightness()) + +subprocess.call( + [ + "dunstify", + "brightness", + "-h", + "int:value:" + get_brightness(), + "-r", + "294893284", + ] +) diff --git a/sway/config.nix b/sway/config.nix new file mode 100644 index 0000000..9c1775f --- /dev/null +++ b/sway/config.nix @@ -0,0 +1,234 @@ +{ pkgs, lib, config, ... }: +let + mod = "Mod4"; + term = "kitty"; + color_bg = "#${config.color.background}"; + color_fg = "#${config.color.foreground}"; + color_active = "#${config.color.green}"; + color_inactive = "#${config.color.cyan}"; + color_indicator = "#${config.color.magenta}"; + color_evil = "#${config.color.red}"; + ws1 = "1"; + ws2 = "2"; + ws3 = "3"; + ws4 = "4"; + ws5 = "5"; + ws6 = "6"; + ws7 = "7"; + ws8 = "8"; + ws9 = "9"; + ws10 = "10"; +in +{ + home-manager.users.zoe.wayland.windowManager.sway.config = { + modifier = mod; + terminal = term; + menu = + "exec rofi -combi-modi window#drun#ssh -show-icons -show combi -modi combi"; + fonts = { + names = [ "CaskaydiaCove Nerd Font" ]; + size = 11.0; + }; + + colors = { + background = color_bg; + focused = { + background = color_bg; + border = color_active; + childBorder = color_active; + indicator = color_indicator; + text = color_fg; + }; + focusedInactive = { + background = color_bg; + border = color_inactive; + childBorder = color_inactive; + indicator = color_indicator; + text = color_fg; + }; + unfocused = { + background = color_bg; + border = color_inactive; + childBorder = color_inactive; + indicator = color_indicator; + text = color_fg; + }; + urgent = { + background = color_bg; + border = color_evil; + childBorder = color_evil; + indicator = color_indicator; + text = color_fg; + }; + }; + + keybindings = lib.mkOptionDefault { + # launch things + ## calculator + "${mod}+c" = "exec rofi -show calc"; + ## emoji + "${mod}+period" = "exec kaokao | xclip -selection clipboard"; + ## THE PICTURES + "${mod}+s" = "exec flameshot gui --clipboard"; + + ## find mouse cursor + "${mod}+x" = + "exec find-cursor --color '#282828' -o 2 --outline-color '#EBDBB2'"; + + ## modes + "${mod}+r" = "mode resize"; + "${mod}+b" = "mode brightness"; + "${mod}+m" = "mode media"; + "${mod}+w" = "mode move"; + "${mod}+v" = "mode focus"; + + ## workspaces + "${mod}+Tab" = "workspace next"; + "${mod}+q" = "exec i3layouts-rofi"; + + ## tablet to next screen + "${mod}+p" = "exec xsetwacom set 'Wacom Intuos S 2 Pen stylus' MapToOutput next"; + }; + + modes = { + resize = { + Escape = "mode default"; + v = "mode focus"; + w = "mode move"; + j = "resize grow height 10 px or 10 ppt"; + l = "resize shrink width 10 px or 10 ppt"; + h = "resize grow width 10 px or 10 ppt"; + k = "resize shrink height 10 px or 10 ppt"; + }; + brightness = { + Escape = "mode default"; + k = "exec /etc/nixos/i3/brightness.py 10+"; + j = "exec /etc/nixos/i3/brightness.py 10-"; + }; + media = { + Escape = "mode default"; + j = "exec --no-startup-id python3 /etc/nixos/i3/volume.py 1%-"; + k = "exec --no-startup-id python3 /etc/nixos/i3/volume.py 1%+"; + m = "exec --no-startup-id amixer set Master toggle"; + n = "exec --no-startup-id amixer set Capture toggle"; + p = "exec --no-startup-id playerctld shift"; + "Shift+j" = "exec --no-startup-id playerctl volume 0.05-"; + "Shift+k" = "exec --no-startup-id playerctl volume 0.05+"; + space = "exec --no-startup-id playerctl play-pause"; + l = "exec playerctl next"; + h = "exec playerctl previous"; + }; + move = { + Escape = "mode default"; + v = "mode focus"; + r = "mode resize"; + j = "exec i3l move down"; + k = "exec i3l move up"; + h = "exec i3l move left"; + l = "exec i3l move right"; + s = "exec i3l swap container with previous"; + Tab = "exec i3-msg move workspace next && i3-msg workspace next"; + "1" = "move workspace ${ws1}"; + "2" = "move workspace ${ws2}"; + "3" = "move workspace ${ws3}"; + "4" = "move workspace ${ws4}"; + "5" = "move workspace ${ws5}"; + "6" = "move workspace ${ws6}"; + "7" = "move workspace ${ws7}"; + "8" = "move workspace ${ws8}"; + "9" = "move workspace ${ws9}"; + "0" = "move workspace ${ws10}"; + }; + focus = { + Escape = "mode default"; + w = "mode move"; + r = "mode resize"; + h = "focus left"; + j = "focus down"; + k = "focus up"; + l = "focus right"; + Tab = "workspace next"; + "1" = "workspace ${ws1}"; + "2" = "workspace ${ws2}"; + "3" = "workspace ${ws3}"; + "4" = "workspace ${ws4}"; + "5" = "workspace ${ws5}"; + "6" = "workspace ${ws6}"; + "7" = "workspace ${ws7}"; + "8" = "workspace ${ws8}"; + "9" = "workspace ${ws9}"; + "0" = "workspace ${ws10}"; + }; + }; + + window = { + titlebar = false; + border = 4; + }; + gaps = { + inner = 0; + outer = 0; + }; + + bars = [{ + position = "top"; + command = "waybar"; + statusCommand = + "i3status-rs $HOME/.config/i3status-rust/config-main.toml"; + fonts = { + names = [ "CaskaydiaCove Nerd Font" ]; + size = 11.0; + }; + colors = { + background = color_bg; + activeWorkspace = { + border = color_active; + background = color_bg; + text = color_active; + }; + inactiveWorkspace = { + border = color_bg; + background = color_bg; + text = color_inactive; + }; + focusedWorkspace = { + border = color_active; + background = color_active; + text = color_bg; + }; + bindingMode = { + background = color_bg; + border = color_bg; + text = color_fg; + }; + }; + }]; + + startup = [ + { + command = "--no-startup-id feh --bg-scale /etc/nixos/wallpaper.png"; + always = true; + } + { + command = "picom --experimental-backends"; + always = true; + } + { + command = "--no-startup-id i3-layouts"; + always = true; + } + ]; + }; + home-manager.users.zoe.xsession.windowManager.i3.extraConfig = '' + set $i3l companion to workspace 1 + set $i3l companion to workspace 2 + set $i3l companion to workspace 3 + set $i3l companion to workspace 4 + set $i3l companion to workspace 5 + set $i3l companion to workspace 6 + set $i3l companion to workspace 7 + set $i3l companion to workspace 8 + set $i3l companion to workspace 9 + set $i3l companion to workspace 10 + ''; +} diff --git a/sway/i3status-rust.nix b/sway/i3status-rust.nix new file mode 100644 index 0000000..95a9825 --- /dev/null +++ b/sway/i3status-rust.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: { + imports = [ ./mainbar.nix ]; + + home-manager.users.zoe.programs.i3status-rust = { + enable = true; + package = pkgs.unstable.i3status-rust; + }; +} diff --git a/sway/mainbar.nix b/sway/mainbar.nix new file mode 100644 index 0000000..b15069f --- /dev/null +++ b/sway/mainbar.nix @@ -0,0 +1,88 @@ +{ config, ... }: + let + music = { + block = "music"; + format = "{$icon $player {$volume_icon $volume|} $play $combo.str(max_w:25,rot_interval:0.5)|}"; + }; + pomodoro = { + block = "pomodoro"; + }; + in +{ + home-manager.users.zoe.programs.i3status-rust.bars.main = { + blocks = [ + music + # audio in + { + block = "sound"; + device_kind = "source"; + format = "$icon"; + driver = "pulseaudio"; + step_width = 1; + } + + # audio out + { + block = "sound"; + format = "{$icon $volume|$icon}"; + driver = "pulseaudio"; + headphones_indicator = true; + step_width = 1; + } + + # brightness + { + block = "backlight"; + } + + # network + { + block = "net"; + format = "$icon $device {$signal_strength $ssid |󰈁}"; + } + + # battery + { + block = "battery"; + driver = "upower"; + format = "$icon $percentage $power"; + full_format = "$icon $percentage $power"; + empty_format = "$icon $percentage $power"; + not_charging_format = "$icon $percentage $power"; + } + pomodoro + # time + { + block = "time"; + format = "$icon $timestamp.datetime(f:%R)"; + timezone = "Europe/Berlin"; + interval = 60; + } + ]; + + settings = { + icons = {icons = "material-nf";}; + theme = { + theme = "gruvbox-light"; + overrides = { + separator = " "; + # background + good_bg = "#${config.color.background}"; + critical_bg = "#${config.color.background}"; + idle_bg = "#${config.color.background}"; + info_bg = "#${config.color.background}"; + seperator_bg = "#${config.color.background}"; + warning_bg = "#${config.color.background}"; + + # foreground + critical_fg = "#${config.color.red}"; + good_fg = "#${config.color.green}"; + info_fg = "#${config.color.foreground}"; + idle_fg = "#${config.color.cyan}"; + separator_fg = "#${config.color.foreground}"; + warning_fg = "#${config.color.yellow}"; + }; + }; + }; + }; +} diff --git a/sway/play_pause.py b/sway/play_pause.py new file mode 100644 index 0000000..4e047c4 --- /dev/null +++ b/sway/play_pause.py @@ -0,0 +1,8 @@ +import subprocess +import audiotools + +try: + subprocess.Popen(["playerctl", "play-pause"]).wait() + audiotools.show_now_playing() +except: + pass diff --git a/sway/settings.nix b/sway/settings.nix new file mode 100644 index 0000000..b77a563 --- /dev/null +++ b/sway/settings.nix @@ -0,0 +1,7 @@ +{ pkgs, lib, ... }: { + imports = [ ./config.nix ]; + home-manager.users.zoe.wayland.windowManager.sway = { + package = pkgs.sway; + enable = true; + }; +} diff --git a/sway/volume.py b/sway/volume.py new file mode 100644 index 0000000..b2eba27 --- /dev/null +++ b/sway/volume.py @@ -0,0 +1,11 @@ +# script that changes the volume and then shows a notfication with it using dunst +import subprocess +import argparse +import audiotools + +parser = argparse.ArgumentParser() +parser.add_argument("volchange") +args = parser.parse_args() + +subprocess.check_output(["amixer", "set", "Master", args.volchange]) +audiotools.display_volume(audiotools.get_amixer_volume()) diff --git a/sync.sh b/sync.sh index fc08189..940ac66 100755 --- a/sync.sh +++ b/sync.sh @@ -7,7 +7,7 @@ git pull # cp -r /etc/nixos/ ./backup # copy over all the files to /etc/nixos/ -sudo cp -ru ./flake.nix ./configuration.nix ./wallpaper.png ./dunst ./helix ./rofi ./i3 ./fish ./kitty ./nvim/ ./disks.nix ./variables.nix ./programs.nix ./defaults.nix ./packages.nix ./home.nix ./services.nix ./user.nix /etc/nixos/ +sudo cp -ru ./flake.nix ./configuration.nix ./wallpaper.png ./dunst ./helix ./rofi ./i3 ./sway ./fish ./kitty ./nvim/ ./disks.nix ./variables.nix ./programs.nix ./defaults.nix ./packages.nix ./home.nix ./services.nix ./user.nix /etc/nixos/ cp -u ./.xinitrc $HOME