Compare commits

...

10 commits

Author SHA1 Message Date
caandt 1fb9627aa7 tmux wrapper 2024-10-18 02:06:09 -05:00
caandt 1a50e9afd1 share 2024-10-18 01:59:25 -05:00
caandt 848a1b6ad3 bin 2024-10-18 01:58:59 -05:00
caandt aad8bcdfd5 stable 2024-10-17 22:01:00 -05:00
caandt 0ab3bf5dd0 split home conf into modules 2024-10-17 21:32:02 -05:00
caandt f5524baf8e block recently used 2024-10-16 00:26:33 -05:00
caandt 7de7a30554 disable useless kde systemd services 2024-10-11 20:25:02 -05:00
caandt c88940f7f1 rm startx 2024-10-11 20:22:54 -05:00
caandt 6419f21619 awesomewm floating window 2024-10-11 20:20:55 -05:00
caandt e18a904ee2 update awesomewm maximize button 2024-10-11 20:07:37 -05:00
13 changed files with 247 additions and 103 deletions

View file

@ -14,29 +14,23 @@
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
overlays = {
nixpkgs.overlays = [
(final: prev: {
stable = import nixpkgs-stable {
system = prev.system;
};
})
];
};
pkgs-stable = nixpkgs-stable.legacyPackages.${system};
in {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
system/configuration.nix
overlays
];
specialArgs = {
inherit pkgs-stable;
};
modules = [ system/configuration.nix ];
};
homeConfigurations.ahnwuoa = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
user/home.nix
overlays
];
extraSpecialArgs = rec {
inherit pkgs-stable;
username = "ahnwuoa";
homeDirectory = "/home/${username}";
};
modules = [ user/home.nix ];
};
};
}

View file

@ -51,7 +51,6 @@
services.xserver = {
enable = true;
autorun = false;
displayManager.startx.enable = true;
displayManager.sx.enable = true;
windowManager.awesome.enable = true;
desktopManager.plasma5.enable = true;
@ -136,6 +135,11 @@
};
security.polkit.enable = true;
systemd.user.services = {
plasma-kactivitymanagerd.enable = false;
plasma-xdg-desktop-portal-kde.enable = false;
};
system.stateVersion = "24.05";
}

19
user/bin.nix Normal file
View file

@ -0,0 +1,19 @@
{ config, pkgs, homeDirectory, ... }:
let
deps = {
bell = [ pkgs.pipewire pkgs.libnotify ];
nsxiv-rifle = [ pkgs.nsxiv ];
screenshot = [ pkgs.maim pkgs.xclip ];
};
mkln = x: config.lib.file.mkOutOfStoreSymlink "${homeDirectory}/.local/nixos/user/bin/${x}";
in {
home.file = builtins.listToAttrs (map
(x: {
name = ".local/bin/${x}";
value = { source = mkln x; };
})
(builtins.attrNames (builtins.readDir ./bin))
);
home.packages = pkgs.lib.lists.flatten (builtins.attrValues deps);
}

7
user/bin/bell Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
WAV="$XDG_DATA_HOME/bell.wav"
if [ -f $WAV ] && [ $(pgrep pw-play | wc -l) -le 10 ]; then
pw-play --volume 0.5 "$WAV" &
else
notify-send "Bell"
fi

36
user/bin/nsxiv-rifle Executable file
View file

@ -0,0 +1,36 @@
#!/bin/sh
TMPDIR="${TMPDIR:-/tmp}"
tmp="$TMPDIR/nsxiv_rifle_$$"
is_img_extension() {
grep -iE '\.(jpe?g|png|gif|svg|webp|tiff|heif|avif|ico|bmp)$'
}
listfiles() {
find -L "///${1%/*}" -maxdepth 1 -type f -print |
is_img_extension | sort -V | tee "$tmp"
}
open_img() {
# only go through listfiles() if the file has a valid img extension
if echo "$1" | is_img_extension >/dev/null 2>&1; then
trap 'rm -f $tmp' EXIT
count="$(listfiles "$1" | grep -nF "$1")"
fi
if [ -n "$count" ]; then
nsxiv -i -n "${count%%:*}" -a -p -- < "$tmp"
else
# fallback incase file didn't have a valid extension, or we couldn't
# find it inside the list
nsxiv -a -p -- "$@"
fi
}
[ "$1" = '--' ] && shift
case "$1" in
"") echo "Usage: ${0##*/} PICTURES" >&2; exit 1 ;;
/*) open_img "$1" ;;
"~"/*) open_img "$HOME/${1#"~"/}" ;;
*) open_img "$PWD/$1" ;;
esac

2
user/bin/screenshot Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
maim -su -f jpg -m 10 | xclip -selection clipboard -t image/png

41
user/bin/sh-tmux Executable file
View file

@ -0,0 +1,41 @@
#!/bin/sh
# tmux wrapper script to attach to unattached sessions and auto number session
new_session () {
n=1
sessions="$(tmux ls -F '#S' 2> /dev/null )"
while :; do
for session in $sessions; do
if [ "$n" = "$session" ]; then
n=$((n+1))
continue 2
fi
done
break
done
tmux new-session -s $n 2> /dev/null
}
attach_session () {
for session in $(tmux ls -F '#{?session_attached,,#S}' 2> /dev/null); do
if [ ! -z "$session" ]; then
tmux attach -t "${session}" 2> /dev/null
return
fi
done
new_session
}
if [ "$1" = "-d" ]; then
SH_TMUX_PID=$(tmux show-environment | sed -n 's/^SH_TMUX_PID=//p')
kill -USR1 $SH_TMUX_PID
tmux detach-client
else
trap 'NOTMUX=y exec $SHELL' USR1
export SH_TMUX_PID=$$
if [ "$1" != "-n" ]; then
attach_session
else
new_session
fi
fi

View file

@ -553,6 +553,26 @@ client.connect_signal("manage", function (c)
end
end)
local function custommaximizedbutton(c)
local widget = awful.titlebar.widget.button(c, "maximized", function(cl)
return not cl.floating and cl.first_tag and awful.layout.get(cl.first_tag.screen) == awful.layout.suit.max
end, function(cl)
if cl.floating then
cl.floating = false
if awful.layout.get(cl.first_tag.screen) ~= awful.layout.suit.max then
change_layout()
end
else
change_layout()
end
end)
local function update()
if not c.valid then tag.disconnect_signal("property::layout", update)
else widget.update() end
end
tag.connect_signal("property::layout", update)
return widget
end
-- Add a titlebar if titlebars_enabled is set to true in the rules.
client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar
@ -585,7 +605,7 @@ client.connect_signal("request::titlebars", function(c)
},
{ -- Right
awful.titlebar.widget.minimizebutton (c),
awful.titlebar.widget.maximizedbutton(c),
custommaximizedbutton (c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal()
},
@ -597,6 +617,13 @@ end)
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
client.connect_signal("property::floating", function(c)
if c.floating then
awful.titlebar(c, {bg = "#7d92c6"})
else
awful.titlebar(c, {bg = beautiful.titlebar_bg_normal})
end
end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)

View file

@ -1,18 +1,19 @@
{ config, pkgs, ... }:
{ config, pkgs, pkgs-stable, username, homeDirectory, ... }:
let
username = "ahnwuoa";
homeDirectory = "/home/${username}";
mkln = x: config.lib.file.mkOutOfStoreSymlink "${homeDirectory}/.local/nixos/user/${x}";
in
{
imports = [
./xdg.nix
./theme.nix
./bin.nix
];
home.username = username;
home.homeDirectory = homeDirectory;
home.packages = with pkgs; [
(pkgs.symlinkJoin {
name = "firefox";
paths = [ pkgs.stable.firefox ];
paths = [ pkgs-stable.firefox ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/firefox \
@ -30,7 +31,7 @@ in
picom
obs-studio
screenkey
pkgs.stable.safeeyes
pkgs-stable.safeeyes
libsForQt5.kcalc
libsForQt5.kolourpaint
libsForQt5.filelight
@ -57,9 +58,6 @@ in
killall
file
alsa-utils
libnotify
(python311.withPackages (python-pkgs: [
python-pkgs.pwntools
# python-pkgs.angr
@ -88,78 +86,5 @@ in
pwninit
patchelf
];
xdg.configFile.alacritty.source = mkln "config/alacritty";
xdg.configFile.awesome.source = mkln "config/awesome";
xdg.configFile.bash.source = mkln "config/bash";
xdg.configFile.fcitx5.source = config/fcitx5;
xdg.configFile.fontconfig.source = config/fontconfig;
xdg.configFile."gdb/gdbinit.py".source = config/gdb/gdbinit.py;
xdg.configFile."gdb/gdbinit".text = ''
source ${pkgs.pwndbg}/share/pwndbg/gdbinit.py
source ~/.config/gdb/gdbinit.py
'';
xdg.configFile.git.source = config/git;
xdg.configFile.lsd.source = config/lsd;
xdg.configFile.picom.source = config/picom;
xdg.configFile.python.source = config/python;
xdg.configFile.qt5ct.source = config/qt5ct;
xdg.configFile.readline.source = config/readline;
xdg.configFile."starship.toml".source = config/starship.toml;
xdg.configFile.sx.source = mkln "config/sx";
xdg.configFile."tmux/tmux.conf".text = (builtins.readFile config/tmux/tmux.conf) + ''
run ${pkgs.tmuxPlugins.vim-tmux-navigator.rtp}
run ${pkgs.tmuxPlugins.sessionist.rtp}
'';
fonts.fontconfig.enable = false;
qt = {
enable = true;
platformTheme.name = "qtct";
style.name = "breeze";
style.package = pkgs.libsForQt5.breeze-qt5;
};
gtk = {
enable = true;
gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
theme = {
name = "Breeze";
package = pkgs.libsForQt5.breeze-gtk;
};
};
home.pointerCursor = {
name = "breeze_cursors";
package = pkgs.libsForQt5.breeze-qt5;
size = 24;
gtk.enable = true;
};
home.file.".icons/default/index.theme".enable = false;
home.file.".icons/breeze_cursors".enable = false;
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = let
image = "nsxiv.desktop";
browser = "firefox.desktop";
text = "nvim.desktop";
media = "mpv.desktop";
in {
"image/jpeg" = image;
"image/png" = image;
"image/gif" = media;
"audio/mpeg" = media;
"audio/ogg" = media;
"audio/vorbis" = media;
"audio/x-vorbis+ogg" = media;
"video/mp4" = media;
"video/mpeg" = media;
"text/plain" = text;
"application/xml" = text;
};
xdg.portal = {
enable = true;
configPackages = [ pkgs.libsForQt5.xdg-desktop-portal-kde ];
extraPortals = [ pkgs.libsForQt5.xdg-desktop-portal-kde ];
config.common.default = "kde";
};
home.stateVersion = "24.05";
}

BIN
user/share/bell.wav Executable file

Binary file not shown.

BIN
user/share/wallpaper.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

27
user/theme.nix Normal file
View file

@ -0,0 +1,27 @@
{ config, pkgs, ... }:
{
qt = {
enable = true;
platformTheme.name = "qtct";
style.name = "breeze";
style.package = pkgs.libsForQt5.breeze-qt5;
};
gtk = {
enable = true;
gtk2.extraConfig = "gtk-recent-files-max-age = 0";
gtk3.extraConfig = { gtk-recent-files-limit = 0; };
theme = {
name = "Breeze";
package = pkgs.libsForQt5.breeze-gtk;
};
};
home.pointerCursor = {
name = "breeze_cursors";
package = pkgs.libsForQt5.breeze-qt5;
size = 24;
gtk.enable = true;
};
home.file.".icons/default/index.theme".enable = false;
home.file.".icons/breeze_cursors".enable = false;
}

62
user/xdg.nix Normal file
View file

@ -0,0 +1,62 @@
{ config, pkgs, homeDirectory, ... }:
let
mkln = x: config.lib.file.mkOutOfStoreSymlink "${homeDirectory}/.local/nixos/user/${x}";
in {
xdg.configFile.alacritty.source = mkln "config/alacritty";
xdg.configFile.awesome.source = mkln "config/awesome";
xdg.configFile.bash.source = mkln "config/bash";
xdg.configFile.fcitx5.source = config/fcitx5;
xdg.configFile.fontconfig.source = config/fontconfig;
xdg.configFile."gdb/gdbinit.py".source = config/gdb/gdbinit.py;
xdg.configFile."gdb/gdbinit".text = ''
source ${pkgs.pwndbg}/share/pwndbg/gdbinit.py
source ~/.config/gdb/gdbinit.py
'';
xdg.configFile.git.source = config/git;
xdg.configFile.lsd.source = config/lsd;
xdg.configFile.picom.source = config/picom;
xdg.configFile.python.source = config/python;
xdg.configFile.qt5ct.source = config/qt5ct;
xdg.configFile.readline.source = config/readline;
xdg.configFile."starship.toml".source = config/starship.toml;
xdg.configFile.sx.source = mkln "config/sx";
xdg.configFile."tmux/tmux.conf".text = (builtins.readFile config/tmux/tmux.conf) + ''
run ${pkgs.tmuxPlugins.vim-tmux-navigator.rtp}
run ${pkgs.tmuxPlugins.sessionist.rtp}
'';
fonts.fontconfig.enable = false;
gtk.gtk2.configLocation = "${config.xdg.configHome}/gtk-2.0/gtkrc";
xdg.dataFile."bell.wav".source = share/bell.wav;
xdg.dataFile."wallpaper.png".source = share/wallpaper.png;
xdg.dataFile."recently-used.xbel".text = "";
xdg.dataFile."RecentDocuments".text = "";
xdg.mimeApps.enable = true;
xdg.mimeApps.defaultApplications = let
image = "nsxiv.desktop";
browser = "firefox.desktop";
text = "nvim.desktop";
media = "mpv.desktop";
in {
"image/jpeg" = image;
"image/png" = image;
"image/gif" = media;
"audio/mpeg" = media;
"audio/ogg" = media;
"audio/vorbis" = media;
"audio/x-vorbis+ogg" = media;
"video/mp4" = media;
"video/mpeg" = media;
"text/plain" = text;
"application/xml" = text;
};
xdg.portal = {
enable = true;
configPackages = [ pkgs.libsForQt5.xdg-desktop-portal-kde ];
extraPortals = [ pkgs.libsForQt5.xdg-desktop-portal-kde ];
config.common.default = "kde";
};
}