Compare commits

..

3 Commits

Author SHA1 Message Date
Nathan McCarty aefc1a93ad
Get vmware shortcut sorted 2023-06-17 13:01:49 -04:00
Nathan McCarty 99d55501de
Update grimshot 2023-06-17 12:42:54 -04:00
Nathan McCarty 3d80cdf667
Shortcuts package 2023-06-17 03:56:31 -04:00
5 changed files with 117 additions and 10 deletions

View File

@ -200,11 +200,11 @@
"nixpkgs": "nixpkgs_3" "nixpkgs": "nixpkgs_3"
}, },
"locked": { "locked": {
"lastModified": 1686925761, "lastModified": 1687002145,
"narHash": "sha256-H+i0VQvc2gx/QUCRNFoLZmHmCDITMQiF9zkDLj0pYCc=", "narHash": "sha256-xJCwdtxIFDImx4XsVzWns8jzh6htcvWhjdrVDNZfjTg=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "contrib", "repo": "contrib",
"rev": "fd07e8b82042c0d2ca0c492df2b8f4854573c7d0", "rev": "fa0b667ef28c0f7e597f916eadb3f8bef48d9ef8",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -281,7 +281,11 @@
}; };
}; };
in { in {
packages = flake-utils.lib.flattenTree { packages = let
writePython311Script =
pkgs.writers.makePythonWriter pkgs.python311 pkgs.python311Packages
pkgs.buildPackages.python311Packages;
in flake-utils.lib.flattenTree {
discordWayland = pkgs.callPackage ./packages/discord/default.nix rec { discordWayland = pkgs.callPackage ./packages/discord/default.nix rec {
pname = "discord-electron"; pname = "discord-electron";
binaryName = "DiscordCanary"; binaryName = "DiscordCanary";
@ -297,6 +301,19 @@
swayimg = pkgs.callPackage ./packages/swayimg/default.nix { }; swayimg = pkgs.callPackage ./packages/swayimg/default.nix { };
hyprland-autoname-workspaces = hyprland-autoname-workspaces =
pkgs.callPackage ./packages/workspace-renamer/default.nix { }; pkgs.callPackage ./packages/workspace-renamer/default.nix { };
shortcuts = let
script = writePython311Script "shortcuts" { }
(builtins.readFile ./scripts/shortcuts/shortcuts.py);
in pkgs.stdenv.mkDerivation {
name = "shortcuts";
src = ./shortcuts;
installPhase = ''
mkdir -p $out/bin
ln -s ${script} $out/bin/shortcuts
mkdir -p $out/shortcuts
cp -r * $out/shortcuts
'';
};
}; };
}); });
} }

View File

@ -10,6 +10,7 @@ in with lib; {
fuzzel -f "Iosevka Sans Quasi" -b "181818dd" -S "b9b9b9ff" -s "252525dd" -t "777777ff" -B 5 -r 5 -C "70b433dd"''; fuzzel -f "Iosevka Sans Quasi" -b "181818dd" -S "b9b9b9ff" -s "252525dd" -t "777777ff" -B 5 -r 5 -C "70b433dd"'';
notif-package = notif-package =
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaynotificationcenter; inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.swaynotificationcenter;
shortcuts = inputs.self.packages.${pkgs.system}.shortcuts;
in { in {
home.packages = with pkgs; [ home.packages = with pkgs; [
# General # General
@ -191,8 +192,8 @@ in with lib; {
bind = , xf86audiomute, exec, swayosd --output-volume mute-toggle bind = , xf86audiomute, exec, swayosd --output-volume mute-toggle
# Screenshots # Screenshots
bind = , print, exec, grimblast copysave area ~/Pictures/Screenshots/$(date -Iseconds).png bind = , print, exec, grimblast --scale 1 copysave area ~/Pictures/Screenshots/$(date -Iseconds).png
bind = SHIFT, print, exec, grimblast copysave output ~/Pictures/Screenshots/$(date -Iseconds).png bind = SHIFT, print, exec, grimblast --scale 1 copysave output ~/Pictures/Screenshots/$(date -Iseconds).png
# Caps lock indicator # Caps lock indicator
bindr = CAPS, caps_lock, exec, swayosd --caps-lock bindr = CAPS, caps_lock, exec, swayosd --caps-lock
@ -203,11 +204,14 @@ in with lib; {
# Notif bind # Notif bind
bind = $mainMod, T, exec, swaync-client -t -sw bind = $mainMod, T, exec, swaync-client -t -sw
# Shortcut dispatcher
bind = $mainMod, W, exec, ${shortcuts}/bin/shortcuts ~/.config/shortcuts/shortcuts.toml
## Window rules ## Window rules
# Gamescope # Gamescope - vmware
windowrulev2 = float,class:^(.gamescope-wrapped)$ windowrulev2 = float,class:^(.gamescope-wrapped)$,title:VMware Workstation
windowrulev2 = noborder,class:^(.gamescope-wrapped)$ windowrulev2 = noborder,class:^(.gamescope-wrapped)$,title:VMware Workstation
windowrulev2 = rounding 0,class:^(.gamescope-wrapped)$ windowrulev2 = rounding 0,class:^(.gamescope-wrapped)$,title:VMware Workstation
# Clipboard history management # Clipboard history management
exec-once=wl-paste --watch cliphist store exec-once=wl-paste --watch cliphist store
@ -256,6 +260,19 @@ in with lib; {
}; };
Install = { WantedBy = [ "graphical-session.target" ]; }; Install = { WantedBy = [ "graphical-session.target" ]; };
}; };
# Shortcut dispatcher
xdg.configFile."shortcuts/shortcuts.toml" = {
text = ''
directories = ["~/.config/shortcuts/shortcuts", "${shortcuts}/shortcuts"]
picker_command = "${
builtins.replaceStrings [ ''"'' ] [ ''\"'' ] fuzzel-command
} --dmenu"
'';
onChange = ''
mkdir -p ~/.config/shortcuts/shortcuts
'';
};
######################### #########################
## SwayNotificationCenter (notifications) ## SwayNotificationCenter (notifications)
######################### #########################

68
scripts/shortcuts/shortcuts.py Executable file
View File

@ -0,0 +1,68 @@
# https://blog.stigok.com/2019/11/05/packing-python-script-binary-nicely-in-nixos.html
import argparse
import tomllib
import os
import subprocess
import sys
from pathlib import Path
def parse_directory(directory):
dictionary = {}
for entry in os.listdir(directory):
path = directory / entry
if path.is_dir():
dictionary[entry] = parse_directory(path)
else:
dictionary[entry] = path
return dictionary
def merge(dict1, dict2):
for key in iter(dict2):
if key in dict1:
if isinstance(dict1[key], dict) and isinstance(dict2[key], dict):
merge(dict1[key], dict2[key])
else:
dict1[key] = dict2[key]
else:
dict1[key] = dict2[key]
parser = argparse.ArgumentParser(prog='shortcuts.py',
description="shortcut dispatcher")
parser.add_argument('config')
args = parser.parse_args()
data = ""
with open(args.config, 'rb') as f:
data = tomllib.load(f)
dicts = []
for dir in data["directories"]:
path = Path(dir).expanduser()
if path.exists():
dicts.append(parse_directory(path))
res = {}
for d in dicts:
merge(res, d)
while isinstance(res, dict):
items = '\n'.join(sorted(res))
proc = subprocess.Popen(data["picker_command"],
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
proc.stdin.write(str.encode(items))
outs, errs = proc.communicate()
outs = outs.decode().strip()
res = res[outs]
proc = subprocess.Popen(res,
stdin=sys.stdin.buffer,
stdout=sys.stdout.buffer,
stderr=sys.stderr.buffer)
proc.wait()

5
shortcuts/vmware/1440p Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
hyprctl dispatch exec -- "[float;size 1829 1029] gamescope -W 2560 -w 2560 -H 1440 -h 1440 --scaler integer --force-windows-fullscreen -- vmware"
wait