Add experimental viewtube

This commit is contained in:
Dmitriy 2019-09-17 02:20:32 +04:00
parent 5642f11a11
commit 9f780383ef
4 changed files with 71 additions and 31 deletions

View File

@ -42,6 +42,9 @@ with import ../support.nix { inherit lib config; }; {
cmd = "${pkgs.xarchiver}/bin/xarchiver";
desktop = "xarchiver";
};
viewtube = {
desktop = "viewtube";
};
# archive = {
# cmd = "${pkgs.ark}/bin/ark";
# desktop = "org.kde.ark";
@ -59,37 +62,38 @@ with import ../support.nix { inherit lib config; }; {
# desktop = "gnumeric";
# };
};
# home-manager.users.alukard.xdg.configFile."mimeapps.list.home".text =
# with config.defaultApplications;
# let
# apps = builtins.mapAttrs (name: value: "${value.desktop}.desktop;") {
# "text/html" = browser;
# # "image/*" = { desktop = "org.kde.gwenview"; };
# "application/x-bittorrent" = torrent;
# "application/zip" = archive;
# "application/rar" = archive;
# "application/7z" = archive;
# "application/*tar" = archive;
# "application/x-kdenlive" = archive;
# "x-scheme-handler/http" = browser;
# "x-scheme-handler/https" = browser;
# "x-scheme-handler/about" = browser;
# "x-scheme-handler/unknown" = browser;
# # "x-scheme-handler/mailto" = mail;
# # "application/pdf" = { desktop = "org.kde.okular"; };
# # "application/vnd.openxmlformats-officedocument.wordprocessingml.document" =
# # text_processor;
# # "application/msword" = text_processor;
# # "application/vnd.oasis.opendocument.text" = text_processor;
# # "text/csv" = spreadsheet;
# # "application/vnd.oasis.opendocument.spreadsheet" = spreadsheet;
# # This actually makes Emacs an editor for everything... XDG is wierd
# "text/plain" = editor;
# };
# in genIni {
# "Default Applications" = apps;
# "Added Associations" = apps;
# };
home-manager.users.alukard.xdg.configFile."mimeapps.list".text =
with config.defaultApplications;
let
apps = builtins.mapAttrs (name: value: "${value.desktop}.desktop;") {
"text/html" = browser;
# "image/*" = { desktop = "org.kde.gwenview"; };
"application/x-bittorrent" = torrent;
"application/zip" = archive;
"application/rar" = archive;
"application/7z" = archive;
"application/*tar" = archive;
"application/x-kdenlive" = archive;
"x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser;
"x-scheme-handler/about" = browser;
"x-scheme-handler/unknown" = browser;
"x-scheme-handler/viewtube" = viewtube;
# "x-scheme-handler/mailto" = mail;
# "application/pdf" = { desktop = "org.kde.okular"; };
# "application/vnd.openxmlformats-officedocument.wordprocessingml.document" =
# text_processor;
# "application/msword" = text_processor;
# "application/vnd.oasis.opendocument.text" = text_processor;
# "text/csv" = spreadsheet;
# "application/vnd.oasis.opendocument.spreadsheet" = spreadsheet;
# This actually makes Emacs an editor for everything... XDG is wierd
"text/plain" = editor;
};
in genIni {
"Default Applications" = apps;
"Added Associations" = apps;
};
home-manager.users.alukard.xdg.configFile."filetypesrc".text = genIni {
EmbedSettings = {
"embed-application/*" = false;

View File

@ -18,6 +18,7 @@
./workspace/misc.nix
./workspace/dunst.nix
./workspace/cursor.nix
./workspace/mpv.nix
./workspace/kde
# ./workspace/synergy.nix
# ./workspace/ssh.nix

32
modules/workspace/mpv.nix Normal file
View File

@ -0,0 +1,32 @@
{ config, lib, pkgs, ... }: {
home-manager.users.alukard.programs.mpv = {
enable = true;
};
home-manager.users.alukard.home.file.".local/share/applications/viewtube.desktop" = {
text = ''
[Desktop Entry]
Name=ViewTube Protocol
Exec=/home/alukard/.scripts/viewtube.sh %u
Type=Application
Terminal=false
MimeType=x-scheme-handler/viewtube
'';
};
home-manager.users.alukard.home.file.".scripts/viewtube.sh" = {
executable = true;
text = ''
#!/usr/bin/env bash
s="$(echo "$1" | sed -e "s/viewtube://")"
v="$(echo "$s" | awk -F 'SEPARATOR' '{print $1}')"
a="$(echo "$s" | awk -F 'SEPARATOR' '{print $2}')"
if [ "$a" = "" ]; then
mpv --hwdec=vaapi --osc --fs --ytdl=yes "$v"
#cvlc -f "$v"
else
mpv --hwdec=vaapi --osc --fs --ytdl=yes --audio-file "$a" "$v"
#cvlc -f --input-slave "$a" "$v"
fi
'';
};
}

View File

@ -41,5 +41,8 @@
};
}
];
shellAliases = {
"mpv" = "mpv --hwdec=vaapi";
};
};
}