b12f-to-master #16

Merged
teutat3s merged 29 commits from refs/pull/16/head into b12f 2021-09-08 22:00:04 +00:00
13 changed files with 284 additions and 1 deletions
Showing only changes of commit bf28a630c9 - Show all commits

View file

@ -1 +1,15 @@
final: prev: { }
final: prev:
with final; {
import-gtk-settings = writeShellScriptBin "import-gtk-settings" (import ./import-gtk-settings.nix final);
mailto-mutt = writeShellScriptBin "mailto-mutt" (import ./mailto-mutt.nix final);
mopidy-jellyfin = import ./mopidy-jellyfin.nix final;
mu = writeShellScriptBin "mu" (import ./mu.nix final);
psos = writeShellScriptBin "psos" (import ./psos.nix final);
s = writeShellScriptBin "s" (import ./s.nix final);
sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final);
sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final);
swaylock-bg = writeScriptBin "swaylock-bg" (import ./swaylock-bg.nix final);
toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final);
uhk-agent = import ./uhk-agent.nix final;
wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);
}

View file

@ -0,0 +1,11 @@
self: with self; ''
# usage: import-gsettings <gsettings key>:<settings.ini key> <gsettings key>:<settings.ini key> ...
expression=""
for pair in "$@"; do
IFS=:; set -- $pair
expressions="$expressions -e 's/^$2=(.*)$/gsettings set org.gnome.desktop.interface $1 \1/e'"
done
IFS=
eval exec sed -E $expressions "$XDG_CONFIG_HOME"/gtk-3.0/settings.ini >/dev/null
''

5
pkgs/mailto-mutt.nix Normal file
View file

@ -0,0 +1,5 @@
self: with self; ''
echo "$@" >> $XDG_CACHE_HOME/log/mailto.log
exec ${alacritty}/bin/alacritty -e neomutt -- "$@"
''

29
pkgs/mopidy-jellyfin.nix Normal file
View file

@ -0,0 +1,29 @@
self: with self;
let
websocket-client = python38.pkgs.buildPythonPackage rec {
pname = "websocket-client";
version = "1.0.0";
doCheck = false;
src = python38.pkgs.fetchPypi {
inherit pname version;
sha256 = "sha256-UFGzii9MJ/vXygd+uyPsaWWmJt7VqVY382vhs1tsT4E=";
};
};
in
python38.pkgs.buildPythonPackage rec {
pname = "Mopidy-Jellyfin";
version = "1.0.2";
doCheck = false;
propagatedBuildInputs = with python38.pkgs; [
unidecode
websocket-client
requests
setuptools
pykka
mopidy
];
src = python38.pkgs.fetchPypi {
inherit pname version;
sha256 = "sha256-5XimIIQSpvNyQbSOFtSTkA0jhA0V68BbyQEQNnov+0g=";
};
}

3
pkgs/mu.nix Normal file
View file

@ -0,0 +1,3 @@
self: with self; ''
exec ${alacritty}/bin/alacritty --class mu_vimpc --option dimensions.columns=120 --option dimensions.lines=80 -e vimpc -- "$@"
''

29
pkgs/psos.nix Normal file
View file

@ -0,0 +1,29 @@
self: with self; ''
case $1 in
rebuild)
shift;
exec sudo nixos-rebuild switch --flake "/etc/nixos#installed-host" $@
;;
update)
shift;
cd /etc/nixos
git pull
exec nix flake update
;;
option)
shift;
exec nixos-option -I nixpkgs=/etc/nixos/lib/compat $@
;;
*)
if [[ "$@" != "" ]]; then
echo "Unknown command: psos $@"
echo ""
fi
echo "Usage: psos [COMMAND]"
echo " rebuild Rebuild the configuration and switch to it"
echo " update Pull git and update flake.lock"
echo " option [path] See the current value for an option in the flake config. Example: psos option nix.nixPath"
exit 1
;;
esac
''

39
pkgs/s.nix Normal file
View file

@ -0,0 +1,39 @@
self: with self; ''
case $1 in
d)
shift;
URL="https://duckduckgo.com?q=$@"
;;
no)
shift;
URL="https://search.nixos.org/options?query=$@"
;;
np)
shift;
URL="https://search.nixos.org/packages?query=$@"
;;
rs)
shift;
URL="https://doc.rust-lang.org/std/index.html?search=$@"
;;
rsc)
shift;
URL="https://docs.rs/releases/search?query=$@"
;;
mdn)
shift;
URL="https://developer.mozilla.org/en-US/search?q=$@"
;;
w)
shift;
URL="https://en.wikipedia.org/w/index.php?search=$@"
;;
*)
URL="https://search.b12f.io?q=$@"
;;
esac
${firefox-wayland}/bin/firefox --new-tab "$URL"
${sway}/bin/swaymsg '[app_id="firefox"]' focus
''

64
pkgs/sway-launcher.nix Normal file
View file

@ -0,0 +1,64 @@
self: with self; ''
#!/usr/bin/env zsh
# terminal application launcher for sway, using fzf
# original command:
# Based on: https://github.com/swaywm/sway/issues/1367
# bindsym $altkey+space exec termite --name=launcher -e \
# "bash -c 'compgen -c | sort -u | fzf --no-extended --print-query | \
# tail -n1 | xargs -r swaymsg -t command exec'"
HIST_FILE="''${XDG_CACHE_HOME:-$HOME/.cache}/sway-launcher-history.txt"
# Get shell command list
# This may include the occasional non-executable file
command_list=$({ whence -wm '*' | sed 's/:[^:]*$//' })
# read existing command history
if [ -f "$HIST_FILE" ]; then
command_history=$(cat "$HIST_FILE")
else
command_history=""
fi
# search command list
command_str=$(printf "%s\n" "''${command_history}" "''${command_list}" | \
sed -E 's/^[0-9]+ (.+)$/\1/' | \
fzf --exact --no-extended --print-query --no-sort | \
tail -n1) || exit 1
if [ "$command_str" = "" ]; then
exit 1
fi
# echo "Command: $command_str"
# using \E flag from perl regex
test "''${command_str#*\\E}" != "$command_str" && echo "command can't contain '\E'"
test "''${command_str#*\\E}" != "$command_str" && exit 1
# get full line from history (with count number)
hist_line=$(echo "$command_history" | grep -Pe "^[0-9]+ \Q$command_str\E$")
# echo "Hist Line: $hist_line"
if [ "$hist_line" = "" ]; then
hist_count=1
else
# Increment usage count
hist_count=$(echo "$hist_line" | sed -E 's/^([0-9]+) .+$/\1/')
hist_count=$((hist_count + 1))
# delete line, to add updated later
# echo "Hist Before: $command_history"
command_history=$(echo "$command_history" | \
grep --invert-match -Pe "^[0-9]+ \Q$command_str\E$")
# echo "Hist After: $command_history"
fi
# update history
update_line="''${hist_count} ''${command_str}"
printf "%s\n" "''${update_line}" "''${command_history}" | \
sort --numeric-sort --reverse > "$HIST_FILE"
# echo "$update_line"
# execute command
echo "$command_str"
${sway}/bin/swaymsg -t command exec "$command_str"
''

6
pkgs/sway-service.nix Normal file
View file

@ -0,0 +1,6 @@
self: with self; ''
# first import environment variables from the login manager
systemctl --user import-environment
# then start the service
exec systemctl --wait --user start sway.service
''

20
pkgs/swaylock-bg.nix Normal file
View file

@ -0,0 +1,20 @@
self: with self; ''
# Dependencies:
# swaylock
# Make sure we aren't running twice
RUNNING=$(ps -A | grep swaylock | wc -l)
if [ $RUNNING -ne 0 ]; then
exit 0
fi
IMAGE=$XDG_CONFIG_HOME/wallpaper.jpg
LOCKARGS=""
for OUTPUT in `${sway}/bin/swaymsg -t get_outputs | jq -r '.[].name'`
do
LOCKARGS="''${LOCKARGS} --image ''${OUTPUT}:''${IMAGE}"
IMAGES="''${IMAGES} ''${IMAGE}"
done
exec ${swaylock}/bin/swaylock $LOCKARGS
''

View file

@ -0,0 +1,14 @@
self: with self; ''
set -e
current_layout=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r '.[] | select(.type == "keyboard") | .xkb_active_layout_index' | head -1)
total_layouts=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r '.[] | select(.type == "keyboard") | .xkb_layout_names | length' | head -1)
next_layout=$(expr $current_layout + 1);
if [ $next_layout -ge $total_layouts ]; then
next_layout=0;
fi
${sway}/bin/swaymsg input '*' xkb_switch_layout "$next_layout"
''

44
pkgs/uhk-agent.nix Normal file
View file

@ -0,0 +1,44 @@
self: with self;
let
uhk-agent-bin = stdenv.mkDerivation rec {
pname = "uhk-agent-bin";
version = "1.5.14";
src = builtins.fetchurl {
url = "https://github.com/UltimateHackingKeyboard/agent/releases/download/v1.5.14/UHK.Agent-1.5.14-linux-x86_64.AppImage";
sha256 = "sha256:1yzh4ixy0cqg02xf84vcqj3h67mkxyzs6jf1h935ay582n70nyqg";
};
phases = [ "installPhase" "patchPhase" ];
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/uhk-agent
chmod +x $out/bin/uhk-agent
'';
};
script = ''
#!${bash}/bin/bash
${appimage-run}/bin/appimage-run ${uhk-agent-bin}/bin/uhk-agent
'';
in
stdenv.mkDerivation rec {
pname = "uhk-agent";
version = "1.5.14";
buildInputs = [
bash
uhk-agent-bin
appimage-run
];
phases = [ "buildPhase" "installPhase" "patchPhase" ];
buildPhase = ''
echo "${script}" >> uhk-agent
'';
installPhase = ''
mkdir -p $out/bin
cp uhk-agent $out/bin/uhk-agent
chmod +x $out/bin/uhk-agent
'';
}

5
pkgs/wcwd.nix Normal file
View file

@ -0,0 +1,5 @@
self: with self; ''
pid=$(${sway}/bin/swaymsg -t get_tree | jq '.. | select(.type?) | select(.type=="con") | select(.focused==true).pid')
ppid=$(pgrep --newest --parent ''${pid})
readlink /proc/''${ppid}/cwd || echo $HOME
''