summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bin/downloads2
-rwxr-xr-xbin/bin/tmux_attach2
-rwxr-xr-xbin/bin/workspace12
3 files changed, 9 insertions, 7 deletions
diff --git a/bin/bin/downloads b/bin/bin/downloads
index 45dc41f..4a5fa7f 100755
--- a/bin/bin/downloads
+++ b/bin/bin/downloads
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
download_dir="$HOME/Downloads"
-target=$(find $download_dir -regex '.*\.\(pdf\|PDF\|djvu\|ps\)' -printf "%f\n" | dmenu -i -p "Open File:")
+target=$(find $download_dir -regex '.*\.\(pdf\|PDF\|djvu\|ps\)' -printf "%T+ %f\n" | sort -r | cut -d' ' -f2- | dmenu -i -p "Open File:")
[[ -n $target ]] && exec zathura "$download_dir/$target"
diff --git a/bin/bin/tmux_attach b/bin/bin/tmux_attach
index 7fd5750..b4b35ee 100755
--- a/bin/bin/tmux_attach
+++ b/bin/bin/tmux_attach
@@ -11,7 +11,7 @@ SESSION=$(echo "$UNION" | dmenu -i -p "Session:" | tr -d '[[:space:]]')
# Rename i3 workspace
! grep -Fxq "$SESSION" <(echo "$ATTACHED_SESSIONS") \
&& command -v i3-msg \
- && i3-msg workspace "$SESSION"
+ && $HOME/bin/workspace gw $SESSION
grep -Fxq "$SESSION" <(echo "$TMUXINATOR") \
&& COMMAND="tmuxinator start $SESSION" \
diff --git a/bin/bin/workspace b/bin/bin/workspace
index 3bf9ea9..b42cc56 100755
--- a/bin/bin/workspace
+++ b/bin/bin/workspace
@@ -11,8 +11,9 @@ workspaces=$(i3-msg -t get_workspaces | awk 'BEGIN {
}' | sort)
act_on_container() {
+
# Get desired workspace
- target=$(echo "$workspaces" | awk '{print $2}' | dmenu -i -p "Select workspace: ")
+ [[ -z $2 ]] && target=$(echo "$workspaces" | awk '{print $2}' | dmenu -i -p "Select workspace: ") || target=$2
# Exit if empty
[[ -z $target ]] && exit
@@ -33,13 +34,14 @@ act_on_workspace() {
focused_number=$(echo "$workspaces" | awk '$3 ~ "true" {print $1}')
focused_name=$(echo "$workspaces" | awk '$3 ~ "true" {print $2}' | cut -d":" -f2)
- [[ $1 = 'n' ]] && new_number=$((focused_number + 1))
- [[ $1 = 'p' ]] && new_number=$((focused_number - 1))
+ [[ $1 = 'n' ]] && new_number=$(( (11+focused_number+1) % 11 ))
+ [[ $1 = 'p' ]] && new_number=$(( (11+focused_number-1) % 11 ))
next=$(echo "${workspaces}" | awk '$1 ~ /'$new_number'/ {print $2}')
i3-msg rename workspace to ${new_number}:${focused_name}
+ # ${variable//pattern} replaces all matches of pattern with nothing
if [[ ! -z "${next// }" ]]; then
name_next=${next#*:}
i3-msg "workspace ${next};\
@@ -49,6 +51,6 @@ act_on_workspace() {
}
# Command to use
-[[ $1 = 'gw' ]] && act_on_container "workspace"
-[[ $1 = 'mc' ]] && act_on_container "move container to workspace"
+[[ $1 = 'gw' ]] && act_on_container "workspace" $2
+[[ $1 = 'mc' ]] && act_on_container "move container to workspace" $2
[[ $1 = 'mw' ]] && act_on_workspace "$2"