Compare commits

...

17 Commits

12 changed files with 283 additions and 39 deletions

16
dwl.switch_context Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
function log_this() {
TSTMP=$(date)
echo "$TSTMP : " $1 >> $DWL_LOG_FILE
}
# ----------------------------------------------------------
# Let DWL start
# ----------------------------------------------------------
log_this "Switch Context: Configuring $(wlr-randr | grep -E "^\w+" | wc -l) displays"
source ~/bin/dwl.randr_setup
log_this "Switch Context: Starting somebar using $SOMEBAR_FIFO"
source ~/bin/dwl.bar_setup

61
dwl_act
View File

@@ -11,6 +11,7 @@ echo "$0 - $timestamp - $act" >> ~/dwl_key_act.log
# #
case $act in case $act in
# Without modifier
vol_mute) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle;; vol_mute) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle;;
vol_lower) wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ 10%-;; vol_lower) wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ 10%-;;
vol_raise) wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ 10%+;; vol_raise) wpctl set-volume --limit 1.0 @DEFAULT_AUDIO_SINK@ 10%+;;
@@ -21,12 +22,68 @@ case $act in
media_stop) mpc stop;; # XF86AudioStop media_stop) mpc stop;; # XF86AudioStop
media_prev) mpc prev;; # XF86AudioPrev media_prev) mpc prev;; # XF86AudioPrev
media_next) mpc next;; # XF86AudioNext media_next) mpc next;; # XF86AudioNext
# disp) ;; disp) /home/mahesh/bin/switch_context.sh;;
# wlan) ;; # wlan) ;;
# tools) ;; # tools) ;;
# search) ;; # search) ;;
launch) wldash;; launch) wldash;;
# explore) ;; # explore) ;;
# print) grim -g "$(slurp)" -t png "$(date +/tmp/grim_%d%b%Y_%H_%M_%S.png)" ;; print) grim -c -g "$(slurp -o -r -c '#ff0000ff')" -t ppm - | satty --filename - --fullscreen --output-filename ~/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png ;;
# With CTRL modifier
# C_vol_mute) ;;
# C_vol_lower) ;;
# C_vol_raise) ;;
# C_mic_mute) ;;
# C_bright_low) ;;
# C_bright_high) ;;
# C_media_toggle) ;;
# C_media_stop) ;;
# C_media_prev) ;;
# C_media_next) ;;
# C_disp) ;;
# C_wlan) ;;
# C_tools) ;;
# C_search) ;;
# C_launch) ;;
# C_explore) ;;
C_print) grim -c -g "$(slurp -d -c '#0000ffff')" -t ppm - | satty --filename - --fullscreen --output-filename ~/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png ;;
# With SHIFT modifier
# S_vol_mute) ;;
# S_vol_lower) ;;
# S_vol_raise) ;;
# S_mic_mute) ;;
# S_bright_low) ;;
# S_bright_high) ;;
# S_media_toggle) ;;
# S_media_stop) ;;
# S_media_prev) ;;
# S_media_next) ;;
# S_disp) ;;
# S_wlan) ;;
# S_tools) ;;
# S_search) ;;
# S_launch) ;;
# S_explore) ;;
# S_print) ;;
# With SHIFT+CTRL modifiers
# SC_vol_mute) ;;
# SC_vol_lower) ;;
# SC_vol_raise) ;;
# SC_mic_mute) ;;
# SC_bright_low) ;;
# SC_bright_high) ;;
# SC_media_toggle) ;;
# SC_media_stop) ;;
# SC_media_prev) ;;
# SC_media_next) ;;
# SC_disp) ;;
# SC_wlan) ;;
# SC_tools) ;;
# SC_search) ;;
# SC_launch) ;;
*) echo "Unknown action '$act'";; *) echo "Unknown action '$act'";;
esac esac

View File

@@ -1,3 +1,3 @@
swayidle -w \ swayidle -w \
timeout 600 'systemctl hybrid-sleep' & timeout 6000 'systemctl hybrid-sleep' &

View File

@@ -1,7 +1,9 @@
mako --font "Iosevka Term" \ # mako --font "Iosevka Term" \
--background-color "#777777AA" \ # --background-color "#777777AA" \
--text-color "#EEEEEE" \ # --text-color "#EEEEEE" \
--border-color "#777777AA" \ # --border-color "#777777AA" \
--border-radius 5 \ # --border-radius 5 \
--default-timeout 5000 & # --default-timeout 5000 &
swaync &

View File

@@ -6,7 +6,7 @@ function die() {
START_DIR=$(pwd) START_DIR=$(pwd)
FILE_DIR="/opt/neovim" FILE_DIR="/opt/neovim"
FILE_NAME="nvim.appimage" FILE_NAME="nvim-linux-x86_64.appimage"
FILE_URL="https://github.com/neovim/neovim/releases/download/nightly" FILE_URL="https://github.com/neovim/neovim/releases/download/nightly"
TMP_FILE=$(mktemp $FILE_DIR/nvim.XXXXXX.appimage) TMP_FILE=$(mktemp $FILE_DIR/nvim.XXXXXX.appimage)

View File

@@ -11,11 +11,12 @@ unless (exists $ENV{'WAYLAND_DISPLAY'}) {
my $app = {}; my $app = {};
$app->{'displays'} = {}; $app->{'displays'} = {};
$app->{'setup'} = "";
get_display_info($app); get_display_info($app);
show_debug(Data::Dumper->Dump([$app])); show_debug(Data::Dumper->Dump([$app]));
my $wlr_line = get_wlr_line($app); my $wlr_line = get_wlr_line($app);
notify($app);
print "${wlr_line}\n"; print "${wlr_line}\n";
# ----------- # -----------
@@ -87,22 +88,25 @@ sub get_display_info {
# ----------- # -----------
sub get_wlr_line { sub get_wlr_line {
my ($app) = @_; my ($app) = @_;
my $matching_disps;
my $wlr_line = "UNKNOWN"; my $wlr_line = "UNKNOWN";
my $num_disps = scalar(keys(%{$app->{'displays'}})); my $num_disps = scalar(keys(%{$app->{'displays'}}));
if ($num_disps == 1) { if ($num_disps == 1) {
show_debug("Single display configuration"); show_debug("Single display configuration");
$app->{'setup'} = "Single display configuration";
$wlr_line = "wlr-randr --output HDMI-A-1 --off --output eDP-1 --on --pos 0,0" $wlr_line = "wlr-randr --output HDMI-A-1 --off --output eDP-1 --on --pos 0,0"
} elsif ($num_disps > 1) { } elsif ($num_disps > 1) {
# Determine setup (Custom) # Determine setup (Custom)
# #
# - Den room (DELL 27" monitor on the left of laptop display) # - Den room (DELL 27" monitor on the left of laptop display)
my $matching_disps = has_display_with_name($app, "DELL U27"); $matching_disps = has_display_with_name($app, "DELL U27");
if (scalar (@{$matching_disps}) == 1) { if (scalar (@{$matching_disps}) == 1) {
my ($h, $v) = get_display_current_dimensions($app, $matching_disps->[0]); my ($h, $v) = get_display_current_dimensions($app, $matching_disps->[0]);
my $disp_name = $matching_disps->[0]->{'name'}; my $disp_name = $matching_disps->[0]->{'name'};
show_debug("Multiple display configuration: Den room"); show_debug("Multiple display configuration: Den room");
$app->{'setup'} = "Multiple display configuration: Den room";
$wlr_line = "wlr-randr --output ${disp_name} --on --pos 0,0 --output eDP-1 --on --pos ${h},0"; $wlr_line = "wlr-randr --output ${disp_name} --on --pos 0,0 --output eDP-1 --on --pos ${h},0";
} }
@@ -114,6 +118,7 @@ sub get_wlr_line {
my ($h, $v) = get_display_current_dimensions($app, $matching_disps->[0]); my ($h, $v) = get_display_current_dimensions($app, $matching_disps->[0]);
my $disp_name = $matching_disps->[0]->{'name'}; my $disp_name = $matching_disps->[0]->{'name'};
show_debug("Multiple display configuration: Media room"); show_debug("Multiple display configuration: Media room");
$app->{'setup'} = "Multiple display configuration: Media room";
$wlr_line = "wlr-randr --output ${disp_name} --on --pos 0,0 --output eDP-1 --on --pos 0,${v}"; $wlr_line = "wlr-randr --output ${disp_name} --on --pos 0,0 --output eDP-1 --on --pos 0,${v}";
} }
@@ -121,6 +126,14 @@ sub get_wlr_line {
show_debug("No displays?!"); show_debug("No displays?!");
} }
# Adjust scale on Apple pane. Assumes that above lines always put eDP-1 as the last display
$matching_disps = has_display_with_name($app, "Apple Computer");
if (scalar (@{$matching_disps}) == 1) {
show_debug("Scaling Apple MacBook Pro display");
$wlr_line .= " --scale 1.5";
}
return $wlr_line; return $wlr_line;
} }
@@ -144,9 +157,20 @@ sub get_display_current_dimensions {
return ($disp->{'current_mode'}->{'horizontal'}, $disp->{'current_mode'}->{'vertical'}); return ($disp->{'current_mode'}->{'horizontal'}, $disp->{'current_mode'}->{'vertical'});
} }
# -----------
sub notify {
my ($app) = @_;
system("notify-send",
"--app-name=get_randr.pl",
"--icon=/usr/share/icons/Adwaita/scalable/devices/video-display.svg",
"--expire-time=5000",
"Display Configuration Changed", "Now set to - $app->{'setup'}");
}
# ----------- # -----------
sub show_debug { sub show_debug {
my ($str) = @_; my ($str) = @_;
# UNCOMMENT TO DEBUG # print "[DEBUG] $str\n"; # UNCOMMENT TO DEBUG # print "[DEBUG] $str\n";
} }

23
ghostty.config Normal file
View File

@@ -0,0 +1,23 @@
# Ghostty configuration
# ---------------------
# Font
font-family = Iosevka Term
font-size = 15
# Theme
# theme = MaterialOcean
theme = 0x96f
# Cursor
cursor-color = #aa2222
cursor-opacity = 0.8
cursor-style = block
cursor-style-blink = false
shell-integration-features = no-cursor
# Window
window-decoration = false
window-padding-x = 5
window-padding-y = 5
window-padding-balance = true

View File

@@ -117,7 +117,7 @@ require('onedark').load()
-- See `:help vim.o` -- See `:help vim.o`
if vim.g.neovide then if vim.g.neovide then
vim.o.guifont = "Iosevka Term:h13" vim.o.guifont = "Iosevka Term:h15"
vim.g.neovide_scale_factor = 1.0 vim.g.neovide_scale_factor = 1.0
end end

114
rofi_sound.pl Executable file
View File

@@ -0,0 +1,114 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
my $selection = $ARGV[0];
my $app = {};
if (defined $selection) {
select_sink($app, $selection);
} else {
show_sinks($app);
}
# -----------
# Subroutines
# -----------
sub show_sinks {
my ($app) = @_;
my @sinks = get_sinks($app);
print join("\n", @sinks);
}
# -----------
sub select_sink {
my ($app, $sink) = @_;
my $wp_h;
my ($id,$name) = $sink =~ /(\d+):(.*)/;
my $seld_sink = "NONE";
my $seld_id = "NONE";
open($wp_h, "pw-cli info $id |") or die "Could not run pw-cli command";
while (my $ln = <$wp_h>) {
if (my ($node_name) = $ln =~ /node.name\s*=\s*"(.*)"/) {
warn "Selected [$id] ($name) - $node_name\n";
$seld_sink = $node_name;
$seld_id = $id;
last;
}
}
enable_sink($app, $seld_sink, $seld_id);
}
# -----------
sub enable_sink {
my ($app, $sink, $id) = @_;
`wpctl set-default $id`;
unmute_master($app);
}
# -----------
sub unmute_master {
my ($app) = @_;
`amixer -c 0 set Master unmute`;
}
# -----------
sub parse_wpctl {
my $wp_h;
open($wp_h, "wpctl status |") or die "Could not run wpctl command";
my @lines = <$wp_h>;
my $section = "None";
my $sub_section = "None";
my $wp_data = {};
foreach my $ln (@lines) {
# Section
if (my ($mat) = $ln =~ /(^(PipeWire)|^(\w+)$)/) {
$section = $mat;
$wp_data->{$section} = {} unless (exists $wp_data->{$section});
}
# Sub-section
if (my ($mat) = $ln =~ /\s+(\w+):$/) {
$sub_section = $mat;
$wp_data->{$section}->{$sub_section} = [] unless (exists $wp_data->{$section}->{$sub_section});
}
# Entries
if (($section ne "None") && ($sub_section ne "None")) {
if (my ($sel, $id, $name) = $ln =~ /\s+(\*)?\s+(\d+)\.\s+(.*?)(\[|$)/) {
my $seld = (defined $sel) ? 1 : 0;
$name =~ s/^\s*//; $name =~ s/\s*$//;
push(@{$wp_data->{$section}->{$sub_section}}, {
'sel' => $seld,
'id' => $id,
'name' => $name
});
}
}
}
$app->{'wp_data'} = $wp_data;
}
# -----------
sub get_sinks {
my ($app) = @_;
parse_wpctl($app);
# warn Data::Dumper->Dump([$app->{'wp_data'}]);
return map { "$_->{'id'}:$_->{'name'}" } @{$app->{'wp_data'}->{'Audio'}->{'Sinks'}}
}

View File

@@ -3,14 +3,23 @@
# -------------------------------- # --------------------------------
# Shell RC # Shell RC
# -------------------------------- # --------------------------------
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;41m\]$(hostname)\[\033[00m\]\[\033[01;34m\] \w\[\033[00m\] \$ ' PS1='${debian_chroot:+($debian_chroot)}\[\033[01;41m\]$(hostnamectl hostname)\[\033[00m\]\[\033[01;34m\] \w\[\033[00m\] \$ '
# #
# Variables # Variables
# #
export EDITOR=n
export PATH=~/bin:$PATH export PATH=~/bin:$PATH
#
# Editor setup
#
export PATH=/opt/neovim:$PATH
export EDITOR=nvim
function n () {
/opt/neovim/nvim $* || nvim $*
}
# #
# Aliases # Aliases
# #
@@ -18,20 +27,10 @@ alias ls='ls -al --color'
alias q=exit alias q=exit
alias a=clear alias a=clear
alias h=history alias h=history
alias e=$EDITOR
# #
# Functions # Functions
# #
function myvim () {
gvim $1 >& /dev/null &
disown %1
}
function n () {
/opt/neovim/nvim $* || nvim $*
}
function hgrep () { function hgrep () {
history | grep $1 history | grep $1
} }
@@ -42,10 +41,10 @@ function pgrep () {
function u2d () { function u2d () {
~mahesh/git/snips/get_neovim.sh ~mahesh/git/snips/get_neovim.sh
~mahesh/git/snips/get_wezterm.sh # ~mahesh/git/snips/get_wezterm.sh
cd cd
if [ -e /etc/arch-release ]; then if [ -e /etc/arch-release ]; then
pacman -Syu pacman --sync --refresh --sysupgrade --noconfirm
elif [ -e /etc/debian_version ]; then elif [ -e /etc/debian_version ]; then
apt update && apt full-upgrade -y && apt autoremove -y apt update && apt full-upgrade -y && apt autoremove -y
else else

View File

@@ -17,9 +17,19 @@ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;92m\]$(hostnamectl hostname)\[\
# #
# Variables # Variables
# #
#export EDITOR=vim
export EDITOR=nvim
export PATH=~/bin:~/.local/bin:$PATH export PATH=~/bin:~/.local/bin:$PATH
export IGNOREEOF=50 # Ignore first 50 Ctrl-D on shell
export GPG_TTY=$(tty)
#
# Editor setup
#
export PATH=/opt/neovim:$PATH
export EDITOR=nvim
function n () {
/opt/neovim/nvim $* || nvim $*
}
# #
# Aliases # Aliases
@@ -28,18 +38,11 @@ alias ls='ls -altrh --color'
alias q=exit alias q=exit
alias a=clear alias a=clear
alias h=history alias h=history
alias e=$EDITOR
alias n=$EDITOR
alias gn='neovide --fork' alias gn='neovide --fork'
# #
# Functions # Functions
# #
function myvim () {
gvim $1 >& /dev/null &
disown %1
}
function pyedit () { function pyedit () {
gedit $1 >& /dev/null & gedit $1 >& /dev/null &
disown %1 disown %1
@@ -54,5 +57,9 @@ function pgrep () {
} }
function start_tmux () { function start_tmux () {
TERM=screen-256color tmux new -A -s DevEnv TERM=screen-256color tmux -u new -A -s DevEnv
}
function start_gitui() {
GPG_TTY=$(tty) gitui
} }

View File

@@ -39,6 +39,7 @@ conky.config = {
--[[ For Somebar ]] --[[ For Somebar ]]
conky.text = [[ conky.text = [[
${if_existing /usr/local/bin/somebar}status${endif} \ ${if_existing /usr/local/bin/somebar}status${endif} \
${if_mpd_playing}${if_match "${mpd_status}" == "Paused"}⏸${else}𝄞${endif} [${mpd_percent}] ${mpd_smart 50}${endif} \
💻 ${cpu}% \ 💻 ${cpu}% \
💾 ${memperc}% \ 💾 ${memperc}% \
${if_existing /sys/class/net/enp0s20f0u1u1u2/operstate up}🌎 ${addr enp0s20f0u1u1u2}${else}\ ${if_existing /sys/class/net/enp0s20f0u1u1u2/operstate up}🌎 ${addr enp0s20f0u1u1u2}${else}\
@@ -48,8 +49,8 @@ ${if_existing /sys/class/net/enp3s0/operstate up}🌎 ${addr enp3s0}${else}\
${if_existing /sys/class/net/wlp4s0/operstate up}📶 ${addr wlp4s0}${else}\ ${if_existing /sys/class/net/wlp4s0/operstate up}📶 ${addr wlp4s0}${else}\
${if_up eth0}🌎 ${addr eth0}${else}\ ${if_up eth0}🌎 ${addr eth0}${else}\
network down ${endif}${endif}${endif}${endif}${endif}${endif} \ network down ${endif}${endif}${endif}${endif}${endif}${endif} \
${execi 600 curl 'wttr.in/~45.54,-122.83?u&format=%c%t'} \ ${execi 600 curl 'wttr.in/~45.5202471,-122.6741948?u&format=%c%t'} \
🔊 ${execi 10 wpctl get-volume 54 | tail -1 | perl -ne 'm/([\d\.]+)/; print scalar (($1>1) ? 100 : ($1*100))'} \ 🔊 ${execi 10 wpctl get-volume 53 | tail -1 | perl -ne 'm/([\d\.]+)/; print scalar (($1>1) ? 100 : ($1*100))'} \
${if_existing /sys/class/power_supply/ADP0/online 1}🔌${else}🔋${endif} ${battery_percent}% \ ${if_existing /sys/class/power_supply/ADP0/online 1}🔌${else}🔋${endif} ${battery_percent}% \
📅 ${time %Y %h %d} \ 📅 ${time %Y %h %d} \
🕑 ${time %I:%M%p %Z} 🕑 ${time %I:%M%p %Z}
@@ -57,6 +58,7 @@ ${if_existing /sys/class/power_supply/ADP0/online 1}🔌${else}🔋${endif} ${ba
--[[ --[[
Reference Reference
${execi 600 curl 'wttr.in/~45.54,-122.83?u&format=%c%t'} \
🌡 ${execi 600 weather fips4105192520 | grep Tempera | awk '{print $2}'}°F | \ 🌡 ${execi 600 weather fips4105192520 | grep Tempera | awk '{print $2}'}°F | \
${execi 1 cat /tmp/dwl.tags.out} | \ ${execi 1 cat /tmp/dwl.tags.out} | \