Scripts and a lot of other things...

This commit is contained in:
Chris Cochrun 2020-12-02 08:58:52 -06:00
parent 93d99b81db
commit fda17aea44
18 changed files with 420 additions and 53 deletions

View file

@ -65,7 +65,7 @@
(fn get-volume [?callback] (fn get-volume [?callback]
(let [cb (or ?callback (fn [] nil))] (let [cb (or ?callback (fn [] nil))]
(awful.spawn.easy_async_with_shell "pamixer --get-volume" cb))) (awful.spawn.easy_async_with_shell "pamixer --get-volume-human" cb)))
;; Table of layouts to cover with awful.layout.inc, order matters. ;; Table of layouts to cover with awful.layout.inc, order matters.
(set awful.layout.layouts [ (set awful.layout.layouts [
@ -426,6 +426,6 @@
(awful.spawn.with_shell "flameshot") (awful.spawn.with_shell "flameshot")
(awful.spawn.with_shell "caffeine") (awful.spawn.with_shell "caffeine")
(awful.spawn.with_shell "nextcloud --background") (awful.spawn.with_shell "nextcloud --background")
(awful.spawn.with_shell "emacs --daemon") (awful.spawn.with_shell "emacs --with-profile --daemon default")
(awful.spawn.with_shell "libinput-gestures-setup start") (awful.spawn.with_shell "libinput-gestures-setup start")
(awful.spawn.with_shell "bluetoothctl power on") (awful.spawn.with_shell "bluetoothctl power on")

View file

@ -10,6 +10,10 @@
(local ctrl "Control") (local ctrl "Control")
(local alt "Mod1") (local alt "Mod1")
(fn get-volume [?callback]
(let [cb (or ?callback (fn [] nil))]
(awful.spawn.easy_async_with_shell "pamixer --get-volume-human" cb)))
(local keybindings (local keybindings
{ {
:globalkeys (gears.table.join :globalkeys (gears.table.join
@ -74,7 +78,7 @@
{:description "restore minimized" :group "client"}) {:description "restore minimized" :group "client"})
;; Prompt ;; Prompt
(awful.key [ modkey ] "r" (fn [] (: (. (awful.screen.focused) :mypromptbox) :run)) (awful.key [ modkey ] "r" (fn [] (awful.spawn "/home/chris/.dotfiles/rofi/launchers-git/run.sh"))
{:description "run prompt" :group "launcher"}) {:description "run prompt" :group "launcher"})
(awful.key [ modkey ] "x" (fn [] (awful.key [ modkey ] "x" (fn []
@ -90,6 +94,10 @@
;; utilities ;; utilities
(awful.key [] "Print" (fn [] (awful.spawn "flameshot gui")) (awful.key [] "Print" (fn [] (awful.spawn "flameshot gui"))
{:description "screenshot" :group "utilities"}) {:description "screenshot" :group "utilities"})
(awful.key [ modkey ] "." (fn [] (awful.spawn "/home/chris/.dotfiles/rofi/launchers-git/emoji.sh"))
{:description "emoji picker" :group "utilities"})
(awful.key [ modkey ] "v" (get-volume)
{:description "See current volume" :group "audio" })
;; Menubar ;; Menubar
;; (awful.key [ modkey ] "p" (fn [] (menubar.show)) ;; (awful.key [ modkey ] "p" (fn [] (menubar.show))
;; {:description "show the menubar" :group "launcher"}) ;; {:description "show the menubar" :group "launcher"})
@ -99,6 +107,8 @@
{:description "launch dired in new emacs frame" :group "apps" }) {:description "launch dired in new emacs frame" :group "apps" })
(awful.key [ modkey ] "i" (fn [] (awful.spawn "emacsclient -c -e '(mu4e)'")) (awful.key [ modkey ] "i" (fn [] (awful.spawn "emacsclient -c -e '(mu4e)'"))
{:description "launch mu4e in new emacs frame" :group "apps" }) {:description "launch mu4e in new emacs frame" :group "apps" })
(awful.key [ modkey shift ] "Return" (fn [] (awful.spawn "emacsclient -c -e '(+eshell/frame)'"))
{:description "launch eshell in new emacs frame" :group "apps" })
(awful.key [ modkey ] "e" (fn [] (awful.spawn "emacsclient -c -a 'emacs'")) (awful.key [ modkey ] "e" (fn [] (awful.spawn "emacsclient -c -a 'emacs'"))
{:description "launch new emacs frame" :group "apps" }) {:description "launch new emacs frame" :group "apps" })
;; rofi ;; rofi

View file

@ -20,12 +20,15 @@
} }
} }
;; floating and centered ;; floating and centered videos from mpv or firefox pnp
{ {
:rule_any { :rule_any {
:class [ :class [
"mpv" "mpv"
] ]
:name [
"Picture-in-Picture"
]
} }
:properties { :properties {
:floating true :floating true
@ -35,6 +38,23 @@
:placement (+ awful.placement.no_offscreen awful.placement.centered) :placement (+ awful.placement.no_offscreen awful.placement.centered)
} }
} }
;; sxiv floating on main screen for quick picture viewing
{
:rule_any {
:class [
"sxiv"
"Sxiv"
]
}
:properties {
:floating true
:raise true
:height 900
:width 1500
:placement (+ awful.placement.no_offscreen awful.placement.centered)
}
}
;; Tell qb to open primarily on the secondary monitor
{ {
:rule_any { :rule_any {
:class [ :class [
@ -45,6 +65,7 @@
:screen (screen.count) :screen (screen.count)
} }
} }
;; floating windows
{ {
:rule_any { :rule_any {
:class [ :class [

View file

@ -1,6 +1,6 @@
#!/usr/bin/env fish #!/usr/bin/env fish
set -U fish_user_paths $fish_user_paths $HOME/.local/bin $HOME/scripts set -U fish_user_paths $fish_user_paths $HOME/.local/bin $HOME/scripts $HOME/.doom-emacs/bin
set TERM "xterm-256color" set TERM "xterm-256color"
set EDITOR "emacsclient -t -a" set EDITOR "emacsclient -t -a"
set VISUAL "emacsclient -c -a emacs" set VISUAL "emacsclient -c -a emacs"

View file

@ -4,3 +4,6 @@ af=scaletempo2
speed=2 speed=2
autofit=70% autofit=70%
geometry=50%:50% geometry=50%:50%
[ytdl]
ytdl-format="bestvideo[height<=720]+bestaudio/best"

View file

@ -0,0 +1,275 @@
-- youtube-quality.lua
--
-- Change youtube video quality on the fly.
--
-- Diplays a menu that lets you switch to different ytdl-format settings while
-- you're in the middle of a video (just like you were using the web player).
--
-- Bound to ctrl-f by default.
local mp = require 'mp'
local utils = require 'mp.utils'
local msg = require 'mp.msg'
local assdraw = require 'mp.assdraw'
local opts = {
--key bindings
toggle_menu_binding = "ctrl+f",
up_binding = "k",
down_binding = "j",
select_binding = "ENTER",
--formatting / cursors
selected_and_active = "▶ - ",
selected_and_inactive = "● - ",
unselected_and_active = "▷ - ",
unselected_and_inactive = "○ - ",
--font size scales by window, if false requires larger font and padding sizes
scale_playlist_by_window=false,
--playlist ass style overrides inside curly brackets, \keyvalue is one field, extra \ for escape in lua
--example {\\fnUbuntu\\fs10\\b0\\bord1} equals: font=Ubuntu, size=10, bold=no, border=1
--read http://docs.aegisub.org/3.2/ASS_Tags/ for reference of tags
--undeclared tags will use default osd settings
--these styles will be used for the whole playlist. More specific styling will need to be hacked in
--
--(a monospaced font is recommended but not required)
style_ass_tags = "{\\fnmonospace}",
--paddings for top left corner
text_padding_x = 5,
text_padding_y = 5,
--other
menu_timeout = 10,
--use youtube-dl to fetch a list of available formats (overrides quality_strings)
fetch_formats = true,
--default menu entries
quality_strings=[[
[
{"4320p" : "bestvideo[height<=?4320p]+bestaudio/best"},
{"2160p" : "bestvideo[height<=?2160]+bestaudio/best"},
{"1440p" : "bestvideo[height<=?1440]+bestaudio/best"},
{"1080p" : "bestvideo[height<=?1080]+bestaudio/best"},
{"720p" : "bestvideo[height<=?720]+bestaudio/best"},
{"480p" : "bestvideo[height<=?480]+bestaudio/best"},
{"360p" : "bestvideo[height<=?360]+bestaudio/best"},
{"240p" : "bestvideo[height<=?240]+bestaudio/best"},
{"144p" : "bestvideo[height<=?144]+bestaudio/best"}
]
]],
}
(require 'mp.options').read_options(opts, "youtube-quality")
opts.quality_strings = utils.parse_json(opts.quality_strings)
local destroyer = nil
function show_menu()
local selected = 1
local active = 0
local current_ytdl_format = mp.get_property("ytdl-format")
msg.verbose("current ytdl-format: "..current_ytdl_format)
local num_options = 0
local options = {}
if opts.fetch_formats then
options, num_options = download_formats()
end
if next(options) == nil then
for i,v in ipairs(opts.quality_strings) do
num_options = num_options + 1
for k,v2 in pairs(v) do
options[i] = {label = k, format=v2}
if v2 == current_ytdl_format then
active = i
selected = active
end
end
end
end
--set the cursor to the currently format
for i,v in ipairs(options) do
if v.format == current_ytdl_format then
active = i
selected = active
break
end
end
function selected_move(amt)
selected = selected + amt
if selected < 1 then selected = num_options
elseif selected > num_options then selected = 1 end
timeout:kill()
timeout:resume()
draw_menu()
end
function choose_prefix(i)
if i == selected and i == active then return opts.selected_and_active
elseif i == selected then return opts.selected_and_inactive end
if i ~= selected and i == active then return opts.unselected_and_active
elseif i ~= selected then return opts.unselected_and_inactive end
return "> " --shouldn't get here.
end
function draw_menu()
local ass = assdraw.ass_new()
ass:pos(opts.text_padding_x, opts.text_padding_y)
ass:append(opts.style_ass_tags)
for i,v in ipairs(options) do
ass:append(choose_prefix(i)..v.label.."\\N")
end
local w, h = mp.get_osd_size()
if opts.scale_playlist_by_window then w,h = 0, 0 end
mp.set_osd_ass(w, h, ass.text)
end
function destroy()
timeout:kill()
mp.set_osd_ass(0,0,"")
mp.remove_key_binding("move_up")
mp.remove_key_binding("move_down")
mp.remove_key_binding("select")
mp.remove_key_binding("escape")
destroyer = nil
end
timeout = mp.add_periodic_timer(opts.menu_timeout, destroy)
destroyer = destroy
mp.add_forced_key_binding(opts.up_binding, "move_up", function() selected_move(-1) end, {repeatable=true})
mp.add_forced_key_binding(opts.down_binding, "move_down", function() selected_move(1) end, {repeatable=true})
mp.add_forced_key_binding(opts.select_binding, "select", function()
destroy()
mp.set_property("ytdl-format", options[selected].format)
reload_resume()
end)
mp.add_forced_key_binding(opts.toggle_menu_binding, "escape", destroy)
draw_menu()
return
end
local ytdl = {
path = "youtube-dl",
searched = false,
blacklisted = {}
}
format_cache={}
function download_formats()
local function exec(args)
local ret = utils.subprocess({args = args})
return ret.status, ret.stdout, ret
end
local function table_size(t)
s = 0
for i,v in ipairs(t) do
s = s+1
end
return s
end
local url = mp.get_property("path")
url = string.gsub(url, "ytdl://", "") -- Strip possible ytdl:// prefix.
-- don't fetch the format list if we already have it
if format_cache[url] ~= nil then
local res = format_cache[url]
return res, table_size(res)
end
mp.osd_message("fetching available formats with youtube-dl...", 60)
if not (ytdl.searched) then
local ytdl_mcd = mp.find_config_file("youtube-dl")
if not (ytdl_mcd == nil) then
msg.verbose("found youtube-dl at: " .. ytdl_mcd)
ytdl.path = ytdl_mcd
end
ytdl.searched = true
end
local command = {ytdl.path, "--no-warnings", "--no-playlist", "-J"}
table.insert(command, url)
local es, json, result = exec(command)
if (es < 0) or (json == nil) or (json == "") then
mp.osd_message("fetching formats failed...", 1)
msg.error("failed to get format list: " .. err)
return {}, 0
end
local json, err = utils.parse_json(json)
if (json == nil) then
mp.osd_message("fetching formats failed...", 1)
msg.error("failed to parse JSON data: " .. err)
return {}, 0
end
res = {}
msg.verbose("youtube-dl succeeded!")
for i,v in ipairs(json.formats) do
if v.vcodec ~= "none" then
local fps = v.fps and v.fps.."fps" or ""
local resolution = string.format("%sx%s", v.width, v.height)
local l = string.format("%-9s %-5s (%-4s / %s)", resolution, fps, v.ext, v.vcodec)
local f = string.format("%s+bestaudio/best", v.format_id)
table.insert(res, {label=l, format=f, width=v.width })
end
end
table.sort(res, function(a, b) return a.width > b.width end)
mp.osd_message("", 0)
format_cache[url] = res
return res, table_size(res)
end
-- register script message to show menu
mp.register_script_message("toggle-quality-menu",
function()
if destroyer ~= nil then
destroyer()
else
show_menu()
end
end)
-- keybind to launch menu
mp.add_key_binding(opts.toggle_menu_binding, "quality-menu", show_menu)
-- special thanks to reload.lua (https://github.com/4e6/mpv-reload/)
function reload_resume()
local playlist_pos = mp.get_property_number("playlist-pos")
local reload_duration = mp.get_property_native("duration")
local time_pos = mp.get_property("time-pos")
mp.set_property_number("playlist-pos", playlist_pos)
-- Tries to determine live stream vs. pre-recordered VOD. VOD has non-zero
-- duration property. When reloading VOD, to keep the current time position
-- we should provide offset from the start. Stream doesn't have fixed start.
-- Decent choice would be to reload stream from it's current 'live' positon.
-- That's the reason we don't pass the offset when reloading streams.
if reload_duration and reload_duration > 0 then
local function seeker()
mp.commandv("seek", time_pos, "absolute")
mp.unregister_event(seeker)
end
mp.register_event("file-loaded", seeker)
end
end

View file

@ -150,11 +150,11 @@ fade-exclude = [
# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) # Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0)
# inactive-opacity = 1 # inactive-opacity = 1
inactive-opacity = 0.7; inactive-opacity = 0.5;
# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) # Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default)
# frame-opacity = 1.0 # frame-opacity = 1.0
frame-opacity = 0.8; frame-opacity = 0.75;
# Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0) # Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0)
# menu-opacity = 1.0 # menu-opacity = 1.0
@ -164,7 +164,7 @@ frame-opacity = 0.8;
inactive-opacity-override = false; inactive-opacity-override = false;
# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) # Default opacity for active windows. (0.0 - 1.0, defaults to 1.0)
active-opacity = 0.8; active-opacity = 0.75;
# Dim inactive windows. (0.0 - 1.0, defaults to 0.0) # Dim inactive windows. (0.0 - 1.0, defaults to 0.0)
# inactive-dim = 0.0 # inactive-dim = 0.0

View file

@ -2079,6 +2079,9 @@ c.url.searchengines = {'DEFAULT': 'https://duckduckgo.com/?q={}',
'yt': 'https://yewtu.be/search?q={}', 'yt': 'https://yewtu.be/search?q={}',
'mel': 'https://melpa.org/#/?q={}', 'mel': 'https://melpa.org/#/?q={}',
'y': 'https://www.youtube.com/results?search_query={}', 'y': 'https://www.youtube.com/results?search_query={}',
'ama': 'https://smile.amazon.com/s?k={}',
'aur': 'https://aur.archlinux.org/packages/?O=0&K={}',
'od': 'https://odysee.com/$/search?q={}',
'aw': 'https://wiki.archlinux.org/index.php?search={}'} 'aw': 'https://wiki.archlinux.org/index.php?search={}'}
## Page(s) to open at the start. ## Page(s) to open at the start.

View file

@ -11,3 +11,4 @@ od https://odysee.com/$/following
tml https://outlook.office.com/mail/inbox tml https://outlook.office.com/mail/inbox
oned https://tfcconnection-my.sharepoint.com/personal/chris_tfcconnection_org/_layouts/15/onedrive.aspx oned https://tfcconnection-my.sharepoint.com/personal/chris_tfcconnection_org/_layouts/15/onedrive.aspx
bw https://bitwarden.tfcconnection.org/#/ bw https://bitwarden.tfcconnection.org/#/
coin https://www.coinbase.com/dashboard

View file

@ -1,17 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
## Author : Aditya Shakya (adi1090x) if [ $(hostname) = "chris-linuxlaptop" ]; then
## Mail : adi1090x@gmail.com style="laptop"
## Github : @adi1090x #echo "this is hidpi"
## Reddit : @adi1090x else
style="desktop"
#echo "this is not hidpi"
fi
# Available Styles rofi -no-lazy-grab -show emoji -modi emoji -theme launchers-git/"$style".rasi
# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234
#
# blurry blurry_full kde_simplemenu kde_krunner launchpad
# gnome_do slingshot appdrawer appfolder column
# row row_center screen row_dock row_dropdown
style="blurry"
rofi -no-lazy-grab -show emoji -theme launchers-git/"$style".rasi

View file

@ -1,18 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
## Author : Aditya Shakya (adi1090x)
## Mail : adi1090x@gmail.com
## Github : @adi1090x
## Reddit : @adi1090x
# Available Styles
# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234
#
# blurry blurry_full kde_simplemenu kde_krunner launchpad
# gnome_do slingshot appdrawer appfolder column
# row row_center screen row_dock row_dropdown
if [ $(hostname) = "chris-linuxlaptop" ]; then if [ $(hostname) = "chris-linuxlaptop" ]; then
style="laptop" style="laptop"
#echo "this is hidpi" #echo "this is hidpi"
@ -21,4 +8,4 @@ else
#echo "this is not hidpi" #echo "this is not hidpi"
fi fi
rofi -no-lazy-grab -show drun -modi drun,window,calc,ssh,run,emoji -theme launchers-git/"$style".rasi rofi -no-lazy-grab -show drun -modi drun -theme launchers-git/"$style".rasi

11
rofi/launchers-git/run.sh Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
if [ $(hostname) = "chris-linuxlaptop" ]; then
style="laptop"
#echo "this is hidpi"
else
style="desktop"
#echo "this is not hidpi"
fi
rofi -no-lazy-grab -show run -modi run -theme launchers-git/"$style".rasi

View file

@ -1,17 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
## Author : Aditya Shakya (adi1090x) if [ $(hostname) = "chris-linuxlaptop" ]; then
## Mail : adi1090x@gmail.com style="laptop"
## Github : @adi1090x #echo "this is hidpi"
## Reddit : @adi1090x else
style="desktop"
#echo "this is not hidpi"
fi
# Available Styles rofi -no-lazy-grab -show window -modi window -theme launchers-git/"$style".rasi
# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234
#
# blurry blurry_full kde_simplemenu kde_krunner launchpad
# gnome_do slingshot appdrawer appfolder column
# row row_center screen row_dock row_dropdown
style="blurry"
rofi -no-lazy-grab -show window -modi drun,window,calc,ssh,run,emoji -theme launchers-git/"$style".rasi

10
scripts/lfgimg.fish Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env fish
for i in [1-10]
set url (curl https://www.lfg.co/page/$i |
rg '<img src="https://www.lfg.co' |
sed 's/\s*<.*="\(.*\)".*/\1/' )
echo $url\n >images.txt
curl -o $i.gif $url
end
#wget -O $i

2
scripts/pacprev.sh Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/sh
pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'

48
scripts/rifle-sxiv.sh Executable file
View file

@ -0,0 +1,48 @@
#!/bin/sh
# Compatible with ranger 1.6.0 through 1.7.*
#
# This script searches image files in a directory, opens them all with sxiv and
# sets the first argument to the first image displayed by sxiv.
#
# This is supposed to be used in rifle.conf as a workaround for the fact that
# sxiv takes no file name arguments for the first image, just the number. Copy
# this file somewhere into your $PATH and add this at the top of rifle.conf:
#
# mime ^image, has sxiv, X, flag f = path/to/this/script -- "$@"
#
# Implementation notes: this script is quite slow because of POSIX limitations
# and portability concerns. First calling the shell function 'abspath' is
# quicker than calling 'realpath' because it would fork a whole process, which
# is slow. Second, we need to append a file list to sxiv, which can only be done
# properly in two ways: arrays (which are not POSIX) or \0 sperated
# strings. Unfortunately, assigning \0 to a variable is not POSIX either (will
# not work in dash and others), so we cannot store the result of listfiles to a
# variable.
if [ $# -eq 0 ]; then
echo "Usage: ${0##*/} PICTURES"
exit
fi
[ "$1" = '--' ] && shift
abspath () {
case "$1" in
/*) printf "%s\n" "$1";;
*) printf "%s\n" "$PWD/$1";;
esac
}
listfiles () {
find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \
'.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z
}
target="$(abspath "$1")"
count="$(listfiles | grep -m 1 -ZznF "$target" | cut -d: -f1)"
if [ -n "$count" ]; then
listfiles | xargs -0 sxiv -n "$count" --
else
sxiv -- "$@" # fallback
fi

View file

@ -1 +0,0 @@
* Inbox

View file

@ -36,14 +36,23 @@ set searchurls.osm https://www.openstreetmap.org/search?query=
set searchurls.mdn https://developer.mozilla.org/en-US/search?q= set searchurls.mdn https://developer.mozilla.org/en-US/search?q=
set searchurls.gentoo_wiki https://wiki.gentoo.org/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search= set searchurls.gentoo_wiki https://wiki.gentoo.org/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search=
set searchurls.qwant https://www.qwant.com/?q= set searchurls.qwant https://www.qwant.com/?q=
set searchengine ser set searchengine d
" For syntax highlighting see https://github.com/tridactyl/vim-tridactyl " For syntax highlighting see https://github.com/tridactyl/vim-tridactyl
" vim: set filetype=tridactyl " vim: set filetype=tridactyl
" Org Capture
command org-capture js -p tri.excmds.exclaim_quiet('org-capture ' + JS_ARG)
" Adding my own bindings
bind v hint -W mpvsafe bind v hint -W mpvsafe
bind F hint -w bind F hint -w
bind gy hint -y bind gy hint -y
bind gc composite get_current_url | org-capture bind gc composite get_current_url | org-capture
bind gC hint -W org-capture bind gC hint -W org-capture
command org-capture js -p tri.excmds.exclaim_quiet('org-capture ' + JS_ARG)
" buffers show as windows
bind b bufferall
" Smoothscroll
set smoothscroll true