Compare commits

...

6 Commits

Author SHA1 Message Date
John Mertz d58589fb3c
Rename debian12 distrobox -> debian 2023-07-21 15:20:15 -04:00
John Mertz b87527f8b0
Enhance idle options
Allow for calling idle with --ignore_mode to run an option beyond the
current sequence limit.

Allow 'dim' as it's own option.

Add 'lock' option to waybar script (and add it to source control in the
first place).

Simplify sequence logic by setting a numerical mode.

Improve help.
2023-07-20 22:07:23 -04:00
John Mertz 02a9dbef29
Fallback icon if weather is unknown
Double-width question mark to match double-width weather icons
2023-07-20 16:12:31 -04:00
John Mertz bbaec67a8c
Simple `tofi` dmenu config
Dipping toes in the water again. Wofi is very slow and I don't like that
Rofi requires unofficial patches for Wayland.
`
2023-07-20 16:10:39 -04:00
John Mertz ad27c1f783
Script to update gnome settings
Should take any modified settings and write them as the default
settings. I do not remember if this actually worked. The intent was so
that, when a terminal was openned using a different profile, those
preferences would become the defaults for new actions. I don't remember
the exact impetus for this either. No longer using gnome-terminal, so
I'm just storing this for posterity.
2023-07-20 16:03:20 -04:00
John Mertz aeffca21f0 gammastep distrobox -> nix 2023-07-20 15:44:13 -04:00
7 changed files with 189 additions and 89 deletions

View File

@ -1,9 +1,9 @@
#!/bin/sh
# distrobox_binary
# name: debian12
# name: debian
USE_DISPLAYS=`cat /var/home/jpm/.spool/wallpaper_outputs`
if [ ! -f /run/.containerenv ] && [ ! -f /.dockerenv ]; then
command="/usr/bin/distrobox-enter -n debian12 -- /var/home/jpm/scripts/sway/wallpaper.pl --path=/var/home/jpm/wallpapers -d $USE_DISPLAYS "
command="/usr/bin/distrobox-enter -n debian -- /var/home/jpm/scripts/sway/wallpaper.pl --path=/var/home/jpm/wallpapers -d $USE_DISPLAYS "
for arg in "$@"; do
if echo "${arg}" | grep -Eq "'|\""; then

View File

@ -24,11 +24,7 @@ unless ($pid) {
open STDOUT, '>>/dev/null';
open STDERR, '>>/dev/null';
if (! -e "/run/.containerenv" && ! -e "/.dockerenv" ) {
exec "exec /bin/distrobox-enter -n debian12 -- gammastep -l $lat_lon -b 0.7:0.3";
} else {
exec "exec gammastep -l $lat_lon -b 0.7:0.3";
}
exec "exec $ENV{HOME}/.dotfiles/nix/bin/gammastep -l $lat_lon -b 0.7:0.3";
}
sub fetch_lat_lon

View File

@ -1,91 +1,136 @@
#!/bin/bash
FADE_TIMEOUT=60 # one minute
DIM_TIMEOUT=120 # two minutes
LOCK_TIMEOUT=300 # five minutes
SLEEP_TIMEOUT=600 # ten minutes
HIBERNATE_TIMEOUT=3600 # one hour
BLFILE="$HOME/.spool/idle.dim"
OPFILE="$HOME/.spool/active_outputs"
NOHIBERNATE="$HOME/.spool/hibernate_inhibitor"
IDLEMODE=$(cat $HOME/.spool/idle_mode)
if [[ -n $2 ]]; then
if [[ $2 == '--ignore_mode' ]]; then
$IDLEMODE='hibernate'
else
echo "Unknown mode $IDLEMODE"
exit
fi
fi
if [[ -z $IDLEMODE ]]; then
IDLEMODE="lock"
fi
if [[ $IDLEMODE == 'none' ]]; then
IDLEMODE=0
elif [[ $IDLEMODE == 'fade' ]]; then
IDLEMODE=1
elif [[ $IDLEMODE == 'dim' ]]; then
IDLEMODE=2
elif [[ $IDLEMODE == 'lock' ]]; then
IDLEMODE=3
elif [[ $IDLEMODE == 'sleep' ]]; then
IDLEMODE=4
elif [[ $IDLEMODE == 'hibernate' ]]; then
IDLEMODE=5
else
echo "Invalid idle_mode '$IDLEMODE'"
fi
FADE_TIMEOUT=60 # one minute
DIM_TIMEOUT=120 # two minutes
LOCK_TIMEOUT=300 # five minutes
DPMS_TIMEOUT=600 # ten minutes
SUSPEND_TIMEOUT=3600 # one hour
function usage() {
echo "usage: $0 <option> [--ignore_mode]
start - Initialize 'swayidle' script. This should be declared in Sway config
stop - Kill 'swayidle' script. Consider idle-inhibitor or sleepmode 'none' instead
daemon - Run 'start' as a presistent background process
mode <mode> - Set the idle_mode: none, fade, dim, lock, sleep, hibernate
fade - First idle action. Fades all windows to show background
unfade - Restore opacity for faded windows
dim - Reduce display brightness to minimum
undim - Restore brightness to level prior to 'dim'
lock - Mark as inactive and start 'swaylock'
unlock - (Run upon unlock) Mark as active again
sleep - Disable displays, but continue background processes
unsleep - Re-enable displays
hibernate - Enter suspend-then-hibernate target
unhibernate - Clean up after waking from hibernation
help - This message
function usage()
{
echo "usage: $0 <option>
start - Initialize 'swayidle' script. This should be declared in Sway config.
stop - Kill 'swayidle' script. Consider idle-inhibitor instead.
fade - First idle action. Fades all windows to show background.
unfade - Restore opacity for faded windows.
dim - Reduce display brightness to minimum.
undim - Restore brightness to level prior to 'dim'.
lock - Mark as inactive and start 'swaylock'.
unlock - (Run upon unlock) Mark as active again.
sleep - Disable displays, but continue background processes.
wake - Re-enable displays.
hibernate - Hibernate.
help - This message."
exit
Idle will result in the following actions in sequence:
fade - 1 minute. Fade all windows by reducing opacity to 0 via Sway IPC
dim - 2 minutes. Dim the display with \`gammactl\`
lock - 5 minutes. Lock the screen with \`swaylock\`
sleep - 10 minutes. Sleep by disabling power to all displays via DPMS
hibernate - 60 minutes. Hibernate by entering 'suspend-then-hibernate.target'
Timeouts define statically in the program.
Idle modes are additive, thus the idle_mode is the final action you would like to run in the
sequence. For example: 'sleep' mode will enable 'fade', 'lock', and 'sleep', but not 'hibernate'
--ignore_mode - Run <option> even if in a lower mode in the sequence
"
exit
}
if [ -z $1 ]; then
echo "Missing argument"
usage
elif [ $1 == "-h" ] || [ $1 == "--help" ] || [ $1 == "help" ]; then
usage
elif [ $1 == "start" ]; then
swayidle -w \
timeout $FADE_TIMEOUT "$0 fade" \
resume "$0 unfade" \
timeout $DIM_TIMEOUT "$0 dim" \
resume "$0 undim" \
timeout $LOCK_TIMEOUT "$0 lock" \
resume "$0 unlock" \
timeout $DPMS_TIMEOUT "$0 sleep" \
resume "$0 wake" \
timeout $SUSPEND_TIMEOUT "$0 hibernate"
elif [ $1 == "stop" ]; then
pkill swayidle
elif [ $1 == "fade" ]; then
if [ ! -e $HOME/.spool/sway-hidden ]; then
kill -USR2 `cat $HOME/.spool/sway-transparency`
fi
elif [ $1 == "unfade" ]; then
if [ -e $HOME/.spool/sway-hidden ]; then
kill -USR2 `cat $HOME/.spool/sway-transparency`
/home/jpm/scripts/sway/displays.pl -w
fi
elif [ $1 == "dim" ]; then
echo $($HOME/scripts/thinkpad/blc.pl %) > $BLFILE
$HOME/scripts/thinkpad/blc.pl = 1 &>-
elif [ $1 == "undim" ]; then
$HOME/scripts/thinkpad/blc.pl = `cat $BLFILE` &>-
elif [ $1 == "lock" ]; then
# Change nick to AFK
#ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
#'screen -S irssi -X stuff "/nick jpmAFK^M"'
:
elif [ $1 == "unlock" ]; then
# Change nick to AFK
#ssh jpm@john.me.tz -i /home/jpm/.ssh/no_pass -t \
#'screen -S irssi -X stuff "/nick jpm^M"'
:
elif [ $1 == "sleep" ]; then
if [ -e $NOHIBERNATE ]; then
::
else
for i in `cat $OPFILE`; do swaymsg "output $i dpms off"; done
fi
elif [ $1 == "wake" ]; then
for i in `cat $OPFILE`; do swaymsg "output $i dpms on"; done
#/home/jpm/scripts/sway/displays.pl
elif [ $1 == "hibernate" ]; then
if [ -e $NOHIBERNATE ]; then
::
else
sudo systemctl start hibernate.target
fi
if [[ -z $1 ]]; then
echo "Missing argument"
usage
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]] || [[ $1 == "help" ]]; then
usage
elif [[ $1 == "start" ]]; then
swayidle -w \
timeout $FADE_TIMEOUT "$0 fade" \
resume "$0 unfade" \
timeout $DIM_TIMEOUT "$0 dim" \
resume "$0 undim" \
timeout $LOCK_TIMEOUT "$0 lock" \
resume "$0 unlock" \
timeout $DPMS_TIMEOUT "$0 sleep" \
resume "$0 unsleep" \
timeout $SUSPEND_TIMEOUT "$0 hibernate" \
resume "$0 unhibernate"
elif [[ $1 == "daemon" ]]; then
nohup $0 start 2>/dev/null &
elif [[ $1 == "stop" ]]; then
pkill swayidle
elif [[ $1 == "fade" ]]; then
if [[ $IDLEMODE -gt 0 ]]; then
if [[ ! -e $HOME/.spool/sway-hidden ]]; then
kill -USR2 $(cat $HOME/.spool/sway-transparency)
fi
fi
elif [[ $1 == "unfade" ]]; then
if [[ -e $HOME/.spool/sway-hidden ]]; then
kill -USR2 $(cat $HOME/.spool/sway-transparency)
# TODO: This is a hack. There's no reason that waybar should be dead.
#$HOME/scripts/sway/displays.pl -w
fi
elif [[ $1 == "dim" ]]; then
if [[ $IDLEMODE -gt 1 ]]; then
# I don't currently have any dimable monitors, so fade was created instead
echo $($HOME/scripts/thinkpad/blc.pl %) >$BLFILE
$HOME/scripts/thinkpad/blc.pl = 1 &>-
fi
elif [[ $1 == "undim" ]]; then
$HOME/scripts/thinkpad/blc.pl = $(cat $BLFILE) &>-
elif [[ $1 == "lock" ]]; then
if [[ $IDLEMODE -gt 2 ]]; then
swaylock -c 00000000
fi
elif [[ $1 == "unlock" ]]; then
kill -USR1 $(pgrep swaylock)
elif [[ $1 == "sleep" ]]; then
if [[ $IDLEMODE -gt 3 ]]; then
for i in $(cat $OPFILE); do swaymsg "output $i dpms off"; done
fi
elif [[ $1 == "unsleep" ]]; then
for i in $(cat $OPFILE); do swaymsg "output $i dpms on"; done
#$HOME/scripts/sway/displays.pl
elif [[ $1 == "hibernate" ]]; then
if [[ $IDLEMODE -gt 4 ]]; then
sudo systemctl suspend-then-hibernate.target
fi
else
echo "Invalid argument: $1"
usage
echo "Invalid argument: $1"
usage
fi

4
tofi/tofi-drun.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
HEIGHT=$(swaymsg -t get_outputs | tr '\n' ' ' | sed -e 's/ */ /g' | sed -e 's/\(.*"focused": [a-z]*\),/\1\n/' | less | grep '"focused": true' | sed -e 's/.*"rect": {[^}]*"height": \([0-9]*\).*/\1/')
/usr/bin/tofi-drun --prompt-text "$ " --height $HEIGHT --config ${HOME}/.dotfiles/tofi/sidebar.toml

15
update_gnome_profile.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
PROFILES=`gsettings get org.gnome.Terminal.ProfilesList list | sed -e 's/\[\(.*\)\]/\1/' |sed -e "s/[\',]//g"`
for i in $PROFILES; do
CURRENT=`gsettings get org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:${i}/ visible-name | sed -e "s/'\(.*\)'/\1/"`
if [[ $1 == $CURRENT ]]; then
for j in `gsettings list-keys org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:${i}/`; do
k=`gsettings get org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:${i}/ $j`
#echo $k
echo gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles/ $j \'$k\'
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles/ $j "$k"
done
exit
fi
done

40
waybar/waybar-idle.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
FILE="$HOME/.spool/idle_mode"
if [ -e $FILE ]; then
MODE=$(cat $FILE)
else
MODE="fade"
echo -n $MODE >$FILE
fi
if [[ $MODE == "none" ]]; then
NEXT="fade"
ICON="☕"
elif [[ $MODE == "fade" ]]; then
ICON="🌌"
NEXT="dim"
elif [[ $MODE == "dim" ]]; then
ICON="⬛"
NEXT="lock"
elif [[ $MODE == "lock" ]]; then
ICON="🔒"
NEXT="sleep"
elif [[ $MODE == "sleep" ]]; then
ICON="💤"
NEXT="hibernate"
elif [[ $MODE == "hibernate" ]]; then
ICON="↯ "
NEXT="none"
else
echo "Invalid mode: $MODE"
fi
if [ -z $1 ] || [ "$1" == "bar" ]; then
echo '{"text":"'$ICON'","icon":"'$ICON'","tooltip":"Change sleep mode ('$MODE')","class":"'$MODE'"}'
elif [ "$1" == "rotate" ]; then
echo -n $NEXT >$FILE
$0 bar
else
echo "Invalid argumuent $1"
fi

View File

@ -37,7 +37,7 @@ my $ref = $json->decode($ret->{_content});
if ($cmd eq 'bar') {
my $temp = $ref->{current}->{temp} - 273.15;
my $icon = $ref->{current}->{weather}->[0]->{icon};
my $icon = $ref->{current}->{weather}->[0]->{icon} //= '';
printf("<span font='Anonymice Nerd Font 18'>%s</span>%.1f%s", $icons{$icon}, ${temp}, "°C");
} elsif ($cmd eq 'notify') {