Add movie mode for watching videos on the external monitor
The screen layout and trayer setup moved from xmonad.hs to a shared screen-layout script. lf opens videos with movie.
This commit is contained in:
@@ -38,6 +38,7 @@ cmd open &{{
|
|||||||
case $(file --mime-type -Lb $f) in
|
case $(file --mime-type -Lb $f) in
|
||||||
text/*) lf -remote "send $id \$$EDITOR \$fx";;
|
text/*) lf -remote "send $id \$$EDITOR \$fx";;
|
||||||
application/json) lf -remote "send $id \$$EDITOR \$fx";;
|
application/json) lf -remote "send $id \$$EDITOR \$fx";;
|
||||||
|
video/*) movie $fx > /dev/null 2> /dev/null;;
|
||||||
*) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;;
|
*) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;;
|
||||||
esac
|
esac
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -68,30 +68,18 @@ myScreenshotDir = "/home/fuxino/Pictures/Screenshots/"
|
|||||||
myScreenshotName :: String
|
myScreenshotName :: String
|
||||||
myScreenshotName = "Screenshot-%Y-%m-%d-%H%M%S.png"
|
myScreenshotName = "Screenshot-%Y-%m-%d-%H%M%S.png"
|
||||||
|
|
||||||
-- Sets up the outputs and the wallpaper, and leaves the tray's monitor in $tray
|
-- Sets up the outputs, the wallpaper and trayer; shared with ~/.local/bin/movie
|
||||||
myScreenLayout :: String
|
myScreenLayout :: String
|
||||||
myScreenLayout =
|
myScreenLayout = "/home/fuxino/.local/bin/screen-layout"
|
||||||
"if xrandr --query | grep -q '^HDMI-1-0 connected'; then"
|
|
||||||
++ " xrandr --output HDMI-1-0 --preferred --primary --output eDP-1 --right-of HDMI-1-0 --preferred; tray=1;"
|
|
||||||
++ " else xrandr --output eDP-1 --preferred --primary --output HDMI-1-0 --off; tray=0; fi"
|
|
||||||
++ "; ~/.fehbg"
|
|
||||||
|
|
||||||
-- Replaces any running trayer, so there's never more than one
|
|
||||||
myTrayer :: String
|
|
||||||
myTrayer =
|
|
||||||
"pkill -x trayer; while pgrep -x trayer > /dev/null; do sleep 0.1; done; \
|
|
||||||
\trayer -l --edge top --align right --SetDockType true \
|
|
||||||
\--SetPartialStrut true --expand true --widthtype request \
|
|
||||||
\--tint 0x232634 --height 18 --monitor $tray"
|
|
||||||
|
|
||||||
-- Safe to re-run (e.g. spawnOnce after this string changes and xmonad restarts)
|
-- Safe to re-run (e.g. spawnOnce after this string changes and xmonad restarts)
|
||||||
myScreenSetup :: String
|
myScreenSetup :: String
|
||||||
myScreenSetup =
|
myScreenSetup =
|
||||||
"sleep 1; " ++ myScreenLayout ++ "; pgrep -x picom > /dev/null || picom -b -c; " ++ myTrayer
|
"sleep 1; " ++ myScreenLayout ++ "; pgrep -x picom > /dev/null || picom -b -c"
|
||||||
|
|
||||||
-- Run when a monitor is (dis)connected; restarts trayer so it moves to the right screen
|
-- Run when a monitor is (dis)connected; restarts trayer so it moves to the right screen
|
||||||
myScreenHotplug :: String
|
myScreenHotplug :: String
|
||||||
myScreenHotplug = myScreenLayout ++ "; " ++ myTrayer
|
myScreenHotplug = myScreenLayout
|
||||||
|
|
||||||
myScratchpads :: [NamedScratchpad]
|
myScratchpads :: [NamedScratchpad]
|
||||||
myScratchpads =
|
myScratchpads =
|
||||||
|
|||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Plays videos on the external monitor only, with the laptop screen off.
|
||||||
|
# Opened from lf for video/* files; restores the normal layout when mpv exits.
|
||||||
|
|
||||||
|
# Single-screen mode only makes sense with the external monitor plugged in
|
||||||
|
if ! xrandr --query | grep -q '^HDMI-1-0 connected'; then
|
||||||
|
exec mpv "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap ~/.local/bin/screen-layout EXIT
|
||||||
|
trap 'exit 130' INT TERM HUP
|
||||||
|
|
||||||
|
xrandr --output eDP-1 --off
|
||||||
|
mpv "$@"
|
||||||
Executable
+21
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Sets up the outputs, wallpaper and trayer for whatever monitors are connected.
|
||||||
|
# Called by xmonad at startup and on monitor (dis)connect, and by `movie` on exit.
|
||||||
|
|
||||||
|
if xrandr --query | grep -q '^HDMI-1-0 connected'; then
|
||||||
|
xrandr --output HDMI-1-0 --preferred --primary --output eDP-1 --right-of HDMI-1-0 --preferred
|
||||||
|
tray=1
|
||||||
|
else
|
||||||
|
xrandr --output eDP-1 --preferred --primary --output HDMI-1-0 --off
|
||||||
|
tray=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
~/.fehbg
|
||||||
|
|
||||||
|
# Replace any running trayer, so there's never more than one
|
||||||
|
pkill -x trayer
|
||||||
|
while pgrep -x trayer > /dev/null; do sleep 0.1; done
|
||||||
|
trayer -l --edge top --align right --SetDockType true \
|
||||||
|
--SetPartialStrut true --expand true --widthtype request \
|
||||||
|
--tint 0x232634 --height 18 --monitor "$tray" > /dev/null 2>&1 &
|
||||||
|
disown
|
||||||
Reference in New Issue
Block a user