clean 🫠

This commit is contained in:
Luca 2023-02-05 03:06:17 +01:00
parent d3435e53a4
commit d16174b447
9565 changed files with 0 additions and 1315422 deletions

View file

@ -1,79 +0,0 @@
Xcursor.theme: Colloid Cursors
Xcursor.size: 24
Xft.antialias: true
Xft.hinting: true
Xft.rgba: rgb
Xft.autohint: true
Xft.hintstyle: hintfull
Xft.lcdfilter: lcdfilter
Xft.dpi: 96
XTerm*renderFont: true
XTerm*faceName: xft:JetBrainsMono Nerd Font, \
xft:JoyPixels:size=12, \
xft:Monospacexr:style=Medium:size=12
XTerm*faceSize: 11
XTerm*utf8: 2
XTerm*locale: true
XTerm.vt100.translations: #override \n\
Ctrl <Key> j: smaller-vt-font() \n\
Ctrl <Key> k: larger-vt-font()
! Every shell is a login shell by default (for inclusion of all necessary environment variables)
XTerm*loginshell: true
! I like a LOT of scrollback...
XTerm*savelines: 16384
! double-click to select whole URLs :D
XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48
! COLORS FOR SXIV
Sxiv.foreground: #bbc2cf
Sxiv.background: #1A2026
Sxiv.font: Roboto:style=bold:size=11
! special
*.foreground: #c5c8c6
*.background: #1d1f21
*.cursorColor: #c5c8c6
! black
*.color0: #282a2e
*.color8: #373b41
! red
*.color1: #a54242
*.color9: #cc6666
! green
*.color2: #8c9440
*.color10: #b5bd68
! yellow
*.color3: #de935f
*.color11: #f0c674
! blue
*.color4: #5f819d
*.color12: #81a2be
! magenta
*.color5: #85678f
*.color13: #b294bb
! cyan
*.color6: #5e8d87
*.color14: #8abeb7
! white
*.color7: #707880
*.color15: #c5c8c6

View file

@ -1,25 +0,0 @@
shopt -s autocd #Allows you to cd into directory merely by typing the directory name.
# Default Programs
export EDITOR="nvim"
export PAGER="less"
export BROWSER="firefox"
export MOVPLAY="mpv"
export PICVIEW="feh"
export SNDPLAY="mpv"
export CM_LAUNCHER=rofi
export TERMINAL="st"
export PULSE_LATENCY_MSEC=60
export TERM="xterm-256color"
# Setting Bash prompt. Capitalizes username and host if root user (my root user uses this same config file).
if [ "$EUID" -ne 0 ]
then export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h\[$(tput setaf 5)\]\[$(tput setaf 1)]-($(tput setaf 5)\W\[$(tput setaf 1)\])\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]"
else export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]ROOT\[$(tput setaf 2)\]@\[$(tput setaf 4)\]$(hostname | awk '{print toupper($0)}') \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]"
fi
# Defult app :
EDITOR=nano

View file

@ -1,2 +0,0 @@
[General]
theme=Matcha-sea-dark

View file

@ -1,14 +0,0 @@
{
"workbench.iconTheme": "material-icon-theme",
"terminal.explorerKind": "external",
"terminal.external.linuxExec": "terminator",
"python.terminal.executeInFileDir": true,
"window.menuBarVisibility": "toggle",
"editor.fontSize": 20,
"editor.fontFamily": "JetBrains Mono",
"editor.minimap.enabled": false,
"terminal.integrated.fontFamily": "JetBrains Mono",
"python.terminal.activateEnvInCurrentTerminal": true,
"workbench.startupEditor": "none",
"workbench.colorTheme": "Sweet Mars"
}

View file

@ -1,64 +0,0 @@
## Import files (Colors, Fonts, Etc)
import:
- ~/.config/alacritty/colors.yml
- ~/.config/alacritty/fonts.yml
## Set environment variables
env:
TERM: alacritty
WINIT_X11_SCALE_FACTOR: '1.0'
## Terminal window settings
window :
dimensions:
columns: 82
lines: 25
padding:
x: 10
y: 10
decorations: full
startup_mode: Windowed
dynamic_title: true
dynamic_padding: true
# scrolling
history: 10000
multiplier: 3
# Background opacity
opacity: 0.80
#title: Alacritty
## Cursor
cursor:
style:
shape: Block
blinking: On
unfocused_hollow: false
## Live config reload
live_config_reload: true
key_bindings:
- { key: V, mods: Control|Shift, action: Paste }
- { key: C, mods: Control|Shift, action: Copy }
- { key: Insert, mods: Shift, action: PasteSelection }
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Equals, mods: Control, action: IncreaseFontSize }
- { key: Plus, mods: Control, action: IncreaseFontSize }
- { key: Minus, mods: Control, action: DecreaseFontSize }
- { key: F11, mods: None, action: ToggleFullscreen }
- { key: Paste, mods: None, action: Paste }
- { key: Copy, mods: None, action: Copy }
- { key: L, mods: Control, action: ClearLogNotice }
- { key: L, mods: Control, chars: "\x0c" }
- { key: PageUp, mods: None, action: ScrollPageUp, mode: ~Alt }
- { key: PageDown, mods: None, action: ScrollPageDown, mode: ~Alt }
- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt }
- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt }

View file

@ -1,33 +0,0 @@
colors:
# Default colors
primary:
background: "#20272E"
foreground: "#d8d8d8"
cursor:
text: CellBackground
cursor: "#d8d8d8"
selection:
text: CellForeground
background: "#d8d8d8"
# Normal colors
normal:
black: '#181818'
red: '#ab4642'
green: '#a1b56c'
yellow: '#f7ca88'
blue: '#7cafc2'
magenta: '#ba8baf'
cyan: '#86c1b9'
white: '#d8d8d8'
# Bright colors
bright:
black: '#585858'
red: '#ab4642'
green: '#a1b56c'
yellow: '#f7ca88'
blue: '#7cafc2'
magenta: '#ba8baf'
cyan: '#86c1b9'
white: '#f8f8f8'

View file

@ -1,29 +0,0 @@
# Colors (Tokyo Night)
# Source: https://github.com/zatchheems/tokyo-night-alacritty-theme
colors:
# Default colors
primary:
background: '#02131a'
foreground: '#b5e8e0'
# Normal colors
normal:
black: '#1a1b26'
red: '#653945'
green: '#3c4349'
yellow: '#4c4c53'
blue: '#695861'
magenta: '#88374a'
cyan: '#985965'
white: '#bcb4b9'
# Bright colors
bright:
black: '#837d81'
red: '#653945'
green: '#3c4349'
yellow: '#4c4c53'
blue: '#695861'
magenta: '#88374a'
cyan: '#985965'
white: '#bcb4b9'

View file

@ -1,30 +0,0 @@
colors:
# Default colors
primary:
background: '#282c34'
foreground: '#bbc2cf'
cursor:
text: CellBackground
cursor: '#528bff'
selection:
text: CellForeground
background: '#3e4451'
normal:
black: '#1c1f24'
red: '#ff6c6b'
green: '#98be65'
yellow: '#da8548'
blue: '#51afef'
magenta: '#c678dd'
cyan: '#5699af'
white: '#202328'
bright:
black: '#5b6268'
red: '#da8548'
green: '#4db5bd'
yellow: '#ecbe7b'
blue: '#3071db' # This is 2257a0 in Doom Emacs but I lightened it.
magenta: '#a9a1e1'
cyan: '#46d9ff'
white: '#dfdfdf'

View file

@ -1,30 +0,0 @@
colors:
# Default colors
primary:
background: "#1D1F21"
foreground: "#bbc2cf"
cursor:
text: CellBackground
cursor: "#dfdfdf"
selection:
text: CellForeground
background: "#3e4451"
normal:
black: "#1c1f24"
red: "#ff6c6b"
green: "#98be65"
yellow: "#da8548"
blue: "#51afef"
magenta: "#c678dd"
cyan: "#5699af"
white: "#202328"
bright:
black: "#5b6268"
red: "#da8548"
green: "#4db5bd"
yellow: "#ecbe7b"
blue: "#3071db" # This is 2257a0 in Doom Emacs but I lightened it.
magenta: "#a9a1e1"
cyan: "#46d9ff"
white: "#dfdfdf"

View file

@ -1,34 +0,0 @@
colors:
# Default colors
primary:
background: '#202328'
foreground: '#d7d7d7'
cursor:
text: CellBackground
cursor: '#d7d7d7'
selection:
text: CellForeground
background: '#3e4451'
# Normal colors
normal:
black: '#1c1f24'
red: '#ff6c6b'
green: '#98be65'
yellow: '#da8548'
blue: '#51afef'
magenta: '#c678dd'
cyan: '#5699af'
white: '#202328'
# Bright colors
bright:
black: '#5b6268'
red: '#da8548'
green: '#4db5bd'
yellow: '#ecbe7b'
blue: '#3071db'
magenta: '#a9a1e1'
cyan: '#46d9ff'
white: '#dfdfdf'

View file

@ -1,52 +0,0 @@
colors:
primary:
background: '#282a36'
foreground: '#f8f8f2'
bright_foreground: '#ffffff'
cursor:
text: CellBackground
cursor: CellForeground
vi_mode_cursor:
text: CellBackground
cursor: CellForeground
search:
matches:
foreground: '#44475a'
background: '#50fa7b'
focused_match:
foreground: '#44475a'
background: '#ffb86c'
bar:
background: '#282a36'
foreground: '#f8f8f2'
hints:
start:
foreground: '#282a36'
background: '#f1fa8c'
end:
foreground: '#f1fa8c'
background: '#282a36'
line_indicator:
foreground: None
background: None
selection:
text: CellForeground
background: '#44475a'
normal:
black: '#21222c'
red: '#ff5555'
green: '#50fa7b'
yellow: '#f1fa8c'
blue: '#bd93f9'
magenta: '#ff79c6'
cyan: '#8be9fd'
white: '#f8f8f2'
bright:
black: '#6272a4'
red: '#ff6e6e'
green: '#69ff94'
yellow: '#ffffa5'
blue: '#d6acff'
magenta: '#ff92df'
cyan: '#a4ffff'
white: '#ffffff'

View file

@ -1,34 +0,0 @@
colors:
# Default colors
primary:
background: '#1d1f21'
foreground: '#d7d7d7'
cursor:
text: CellBackground
cursor: '#d7d7d7'
selection:
text: CellForeground
background: '#3e4451'
# Normal colors
normal:
black: '#282828'
red: '#cc241d'
green: '#98971a'
yellow: '#d79921'
blue: '#458588'
magenta: '#b16286'
cyan: '#689d6a'
white: '#a89984'
# Bright colors
bright:
black: '#928374'
red: '#fb4934'
green: '#b8bb26'
yellow: '#fabd2f'
blue: '#83a598'
magenta: '#d3869b'
cyan: '#8ec07c'
white: '#ebdbb2'

View file

@ -1,33 +0,0 @@
colors:
# Default colors
primary:
background: "#161616"
foreground: "#c5c8c6"
cursor:
text: CellBackground
cursor: "#d7d7d7"
selection:
text: CellForeground
background: "#525252"
# Normal colors
normal:
black: "#222222"
red: "#e84f4f"
green: "#b7ce42"
yellow: "#fea63c"
blue: "#66aabb"
magenta: "#b668c7"
cyan: "#6d878d"
white: "#dddddd"
# Bright colors
bright:
black: "#666666"
red: "#d23d3d"
green: "#bde077"
yellow: "#ffe863"
blue: "#aaccbb"
magenta: "#e16a98"
cyan: "#42717b"
white: "#cccccc"

View file

@ -1,32 +0,0 @@
colors:
# Default colors
primary:
background: '#1d1f21'
foreground: '#d7d7d7'
cursor:
text: CellBackground
cursor: '#d7d7d7'
selection:
text: CellForeground
background: '#3e4451'
# Normal colors
normal:
black: '#1d1f21'
red: '#b24040'
green: '#2ebe8f'
yellow: '#dc8531'
blue: '#518fd8'
magenta: '#865596'
cyan: '#72b7c9'
white: '#707880'
# Bright colors
bright:
black: '#373b41'
red: '#cc6666'
green: '#b5bd68'
yellow: '#f0c674'
blue: '#709abe'
magenta: '#af85bb'
cyan: '#8abeb7'
white: '#c5c8c6'

View file

@ -1,33 +0,0 @@
colors:
# Default colors
primary:
background: "#1d1f21"
foreground: "#c5c8c6"
cursor:
text: CellBackground
cursor: "#d7d7d7"
selection:
text: CellForeground
background: "#3e4451"
# Normal colors
normal:
black: "#282a2e"
red: "#a54242"
green: "#8c9440"
yellow: "#de935f"
blue: "#5f819d"
magenta: "#85678f"
cyan: "#5e8d87"
white: "#707880"
# Bright colors
bright:
black: "#373b41"
red: "#cc6666"
green: "#b5bd68"
yellow: "#f0c674"
blue: "#81a2be"
magenta: "#b294bb"
cyan: "#8abeb7"
white: "#c5c8c6"

View file

@ -1,32 +0,0 @@
colors:
# Default colors
primary:
background: '#1d1f21'
foreground: '#c5c8c6'
cursor:
text: CellBackground
cursor: '#ffffff'
selection:
text: CellForeground
background: '#3e4451'
# Normal colors
normal:
black: '#1d1f21'
red: '#cc6666'
green: '#b5bd68'
yellow: '#e6c547'
blue: '#81a2be'
magenta: '#b294bb'
cyan: '#70c0ba'
white: '#373b41'
# Bright colors
bright:
black: '#666666'
red: '#ff3334'
green: '#9ec400'
yellow: '#f0c674'
blue: '#81a2be'
magenta: '#b77ee0'
cyan: '#54ced6'
white: '#282a2e'

View file

@ -1,33 +0,0 @@
colors:
# Default colors
primary:
background: "#1d1f21"
foreground: "#c5c8c6"
cursor:
text: CellBackground
cursor: '#d7d7d7'
selection:
text: CellForeground
background: '#3e4451'
# Normal colors
normal:
black: "#1d1f21"
red: "#cc241d"
green: "#98971a"
yellow: "#d7992a"
blue: "#458588"
magenta: "#b16286"
cyan: "#689d6a"
white: "#c5c8c6"
# Bright colors
bright:
black: "#969896"
red: "#fb4934"
green: "#b8bb26"
yellow: "#fabd2f"
blue: "#83a598"
magenta: "#d3869b"
cyan: "#8ec07c"
white: "#d7d7d7"

View file

@ -1,33 +0,0 @@
colors:
# Default colors
primary:
background: "#101010"
foreground: "#d2c5bc"
cursor:
text: CellBackground
cursor: "#d7d7d7"
selection:
text: CellForeground
background: "#3e4451"
# Normal colors
normal:
black: "#202020"
red: "#b91e2e"
green: "#81957c"
yellow: "#f9bb80"
blue: "#356579"
magenta: "#55365e"
cyan: "#0b3452"
white: "#909090"
# Bright colors
bright:
black: "#606060"
red: "#d14548"
green: "#a7b79a"
yellow: "#fae3a0"
blue: "#7491a1"
magenta: "#87314e"
cyan: "#0f829d"
white: "#fff0f0"

View file

@ -1,45 +0,0 @@
# Font configuration
font:
# Normal (roman) font face
normal:
family: "JetBrainsMono Nerd Font"
#family: "Fantasque Sans Mono"
#family: "Monospace"
#style: Regular
# Bold font face
bold:
family: "JetBrainsMono Nerd Font"
#family: "Fantasque Sans Mono"
#family: "Monospace"
#style: Bold
# Italic font face
italic:
family: "JetBrainsMono Nerd Font"
#family: "Fantasque Sans Mono"
#family: "Monospace"
#style: Italic
# Bold italic font face
bold_italic:
family: "JetBrainsMono Nerd Font"
#family: "Fantasque Sans Mono"
#family: "Monospace"
#style: Bold Italic
# Point size
#JetBrains && Monospace
size: 14
#Fantasque Sans Mono
#size: 14
# Offset
#offset:
# x: 0
# y: 0
# Glyph offset
#glyph_offset:
# x: 0
# y: 0

View file

@ -1,16 +0,0 @@
#!/bin/sh
# Applets :
nm-applet &
#blueman-applet &
#volumeicon &
xfce4-power-manager &
# Wallpaper :
nitrogen --restore &
# Compositor :
autostart="picom"
for program in $autostart; do
pidof -s "$program" || setsid -f "$program"
done >/dev/null 2>&1

View file

@ -1,288 +0,0 @@
-- ## Keybindings ##
-- ~~~~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require("awful")
local hotkeys_popup = require("awful.hotkeys_popup")
-- vars
-- ~~~~~~~~~
-- modkey
local modkey = "Mod4"
-- modifer keys
local shift = "Shift"
local ctrl = "Control"
local alt = "Mod1"
-- Default Applications :
terminal = "alacritty"
editor = os.getenv("EDITOR") or "nano"
editor_cmd = terminal .. " -e " .. editor
-- Configurations
-- ~~~~~~~~~~~~~~
-- # Mouse bindings :
awful.mouse.append_global_mousebindings({
awful.button({ }, 3, function () mymainmenu:toggle() end)
})
client.connect_signal("request::default_mousebindings", function()
awful.mouse.append_client_mousebindings({ awful.button({ }, 1, function (c)
c:activate { context = "mouse_click" }
end),
awful.button({ modkey }, 1, function (c)
c:activate { context = "mouse_click", action = "mouse_move" }
end),
awful.button({ modkey }, 3, function (c)
c:activate { context = "mouse_click", action = "mouse_resize"}
end),
})
end)
-- Sloppy focus :
client.connect_signal("mouse::enter", function(c)
c:activate { context = "mouse_enter", raise = false }
end)
-- # Key bindings :
-- General Awesome keys
awful.keyboard.append_global_keybindings({
awful.key({ modkey, }, "s", hotkeys_popup.show_help, {description="show help", group="awesome"}),
awful.key({ modkey, }, "w", function () mymainmenu:show() end, {description = "show main menu", group = "awesome"}),
awful.key({ modkey, ctrl }, "r", awesome.restart, {description = "reload awesome", group = "awesome"}),
awful.key({ modkey, shift }, "q", awesome.quit, {description = "quit awesome", group = "awesome"}),
awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end, {description = "open a terminal", group = "launcher"}),
awful.key({ modkey, shift }, "Return", function () awful.spawn("xterm") end, {description = "open a terminal", group = "launcher"}),
-- awful.key({ modkey }, "p", function() menubar.show() end,
-- {description = "show the menubar", group = "launcher"}),
})
-- Tags related keybindings
awful.keyboard.append_global_keybindings({
awful.key({ modkey, }, "Left", awful.tag.viewprev, {description = "view previous", group = "tag"}),
awful.key({ modkey, }, "Right", awful.tag.viewnext, {description = "view next", group = "tag"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore, {description = "go back", group = "tag"}),
})
-- Focus related keybindings
awful.keyboard.append_global_keybindings({
awful.key({ modkey, }, "j", function () awful.client.focus.byidx(1) end, {description = "focus next by index", group = "client"}),
awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) end, {description = "focus previous by index", group = "client"}),
awful.key({ modkey, }, "Tab", function () awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end, {description = "go back", group = "client"}),
awful.key({ modkey, ctrl }, "j", function () awful.screen.focus_relative( 1) end, {description = "focus the next screen", group = "screen"}),
awful.key({ modkey, ctrl }, "k", function () awful.screen.focus_relative(-1) end, {description = "focus the previous screen", group = "screen"}),
awful.key({ modkey, ctrl }, "n",
function ()
local c = awful.client.restore()
-- Focus restored client
if c then
c:activate { raise = true, context = "key.unminimize" }
end
end, {description = "restore minimized", group = "client"}),
})
-- Layout related keybindings
awful.keyboard.append_global_keybindings({
awful.key({ modkey, shift }, "j", function () awful.client.swap.byidx( 1) end, {description = "swap with next client by index", group = "client"}),
awful.key({ modkey, shift }, "k", function () awful.client.swap.byidx( -1) end, {description = "swap with previous client by index", group = "client"}),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto, {description = "jump to urgent client", group = "client"}),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, {description = "increase master width factor", group = "layout"}),
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, {description = "decrease master width factor", group = "layout"}),
awful.key({ modkey, shift }, "h", function () awful.tag.incnmaster( 1, nil, true) end, {description = "increase the number of master clients", group = "layout"}),
awful.key({ modkey, shift }, "l", function () awful.tag.incnmaster(-1, nil, true) end, {description = "decrease the number of master clients", group = "layout"}),
awful.key({ modkey, ctrl }, "h", function () awful.tag.incncol( 1, nil, true) end, {description = "increase the number of columns", group = "layout"}),
awful.key({ modkey, ctrl }, "l", function () awful.tag.incncol(-1, nil, true) end, {description = "decrease the number of columns", group = "layout"}),
awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, {description = "select next", group = "layout"}),
awful.key({ modkey, shift }, "space", function () awful.layout.inc(-1) end, {description = "select previous", group = "layout"}),
})
-- Tags related keybindings
awful.keyboard.append_global_keybindings({
awful.key {
modifiers = { modkey },
keygroup = "numrow",
description = "only view tag",
group = "tag",
on_press = function (index)
local screen = awful.screen.focused()
local tag = screen.tags[index]
if tag then
tag:view_only()
end
end,
},
awful.key {
modifiers = { modkey, ctrl },
keygroup = "numrow",
description = "toggle tag",
group = "tag",
on_press = function (index)
local screen = awful.screen.focused()
local tag = screen.tags[index]
if tag then
awful.tag.viewtoggle(tag)
end
end,
},
awful.key {
modifiers = { modkey, shift },
keygroup = "numrow",
description = "move focused client to tag",
group = "tag",
on_press = function (index)
if client.focus then
local tag = client.focus.screen.tags[index]
if tag then
client.focus:move_to_tag(tag)
end
end
end,
},
awful.key {
modifiers = { modkey, ctrl, shift },
keygroup = "numrow",
description = "toggle focused client on tag",
group = "tag",
on_press = function (index)
if client.focus then
local tag = client.focus.screen.tags[index]
if tag then
client.focus:toggle_tag(tag)
end
end
end,
},
awful.key {
modifiers = { modkey },
keygroup = "numpad",
description = "select layout directly",
group = "layout",
on_press = function (index)
local t = awful.screen.focused().selected_tag
if t then
t.layout = t.layouts[index] or t.layout
end
end,
}
})
-- Media Control :
awful.keyboard.append_global_keybindings({
-- Volume Keys :
awful.key({}, "XF86AudioLowerVolume", function () awful.spawn("amixer -q -D pulse sset Master 5%-", false) end),
awful.key({}, "XF86AudioRaiseVolume", function () awful.spawn("amixer -q -D pulse sset Master 5%+", false) end),
awful.key({}, "XF86AudioMute", function () awful.spawn("amixer -D pulse set Master 1+ toggle", false) end),
-- Media Keys :
awful.key({}, "XF86AudioPlay", function() awful.spawn("playerctl play-pause", false) end),
awful.key({}, "XF86AudioNext", function() awful.spawn("playerctl next", false) end),
awful.key({}, "XF86AudioPrev", function() awful.spawn("playerctl previous", false) end),
-- Brightness Keys :
awful.key({}, "XF86MonBrightnessUp", function() awful.spawn("brightnessctl set 5%+", false) end),
awful.key({}, "XF86MonBrightnessDown", function() awful.spawn("brightnessctl set 5%-", false) end),
})
-- Standard program :
awful.keyboard.append_global_keybindings({
-- File Manager :
awful.key({ ctrl, shift }, "f", function () awful.spawn(string.format("pcmanfm")) end, {description = "pcmanfm", group = "file manager"}),
-- Screenshots Keys :
awful.key({ }, "Print", function () awful.spawn("screenshot")end, {description = "Maim", group = "screenshot"}),
awful.key({ modkey }, "Print", function () awful.spawn("screenshot-select")end, {description = "Maim", group = "screenshot"}),
-- Rofi :
awful.key({ modkey }, "p", function () awful.spawn("rofi -show drun -show-icons &>> /tmp/rofi.log") end, {description = "rofi launcher", group = "launcher"}),
-- ClipMenu :
awful.key({ modkey}, "Insert", function () awful.spawn("clipmenu") end,{description = "clipboard history by rofi/clipmenud", group = "awesome"}),
-- Firefox :
awful.key({ modkey }, "b", function () awful.spawn("firefox") end, {description = "Firefox", group = "Web Browser"}),
-- Center Window :
awful.key({ modkey }, "y", awful.placement.centered)
})
-- Systray :
--awful.keyboard.append_global_keybindings({
-- awful.key({ modkey }, "=", function () awful.screen.focused().systray.visible = not awful.screen.focused().systray.visible end, {description = "Toggle systray visibility", group = "custom"})
--})
-- Bar :
awful.keyboard.append_global_keybindings({
awful.key({ modkey }, "=", function ()
for s in screen do
s.mywibar.visible = not s.mywibar.visible
end
end,
{description = "toggle wibox", group = "awesome"}),
})
awful.keyboard.append_global_keybindings({
awful.key({ alt }, "Tab", function() awesome.emit_signal("sidebar::toggle") end), -- Sidebar
awful.key({ alt }, "t", function() awful.titlebar.toggle(client.focus) end),
})
-- Client :
client.connect_signal("request::default_keybindings", function()
awful.keyboard.append_client_keybindings({
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen c:raise() end, {description = "toggle fullscreen", group = "client"}),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,{description = "close", group = "client"}),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,{description = "toggle floating", group = "client"}),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end, {description = "move to master", group = "client"}),
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, {description = "move to screen", group = "client"}),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, {description = "toggle keep on top", group = "client"}),
-- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus.
awful.key({ modkey, }, "n", function (c) c.minimized = true end , {description = "minimize", group = "client"}),
awful.key({ modkey, }, "m", function (c)c.maximized = not c.maximized c:raise() end , {description = "(un)maximize", group = "client"}),
awful.key({ modkey, "Control" }, "m", function (c) c.maximized_vertical = not c.maximized_vertical c:raise() end , {description = "(un)maximize vertically", group = "client"}),
awful.key({ modkey, "Shift" }, "m", function (c) c.maximized_horizontal = not c.maximized_horizontal c:raise() end , {description = "(un)maximize horizontally", group = "client"}),
})
end)

View file

@ -1,42 +0,0 @@
-- ## Layouts ##
-- ~~~~~~~~~~~~~~~~~
-- requirements
-- ~~~~~~~~~~~~
local gears = require("gears")
local awful = require("awful")
local bling = require("lib.bling")
--- Custom Layouts
local mstab = bling.layout.mstab
local centered = bling.layout.centered
local equal = bling.layout.equalarea
local deck = bling.layout.deck
local vertical = bling.layout.vertical
local horizontal = bling.layout.horizontal
-- Tag layout :
tag.connect_signal("request::default_layouts", function()
awful.layout.append_default_layouts({
awful.layout.suit.tile,
awful.layout.suit.floating,
--awful.layout.suit.tile.left,
mstab,
--awful.layout.suit.tile.bottom,
--awful.layout.suit.tile.top,
--awful.layout.suit.fair,
--awful.layout.suit.fair.horizontal,
--awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
--awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
--awful.layout.suit.magnifier,
--awful.layout.suit.corner.nw,
centered,
equal,
deck,
--vertical,
--horizontal,
})
end)

View file

@ -1,140 +0,0 @@
-- Rules
-- ~~~~~
-- requirements
-- ~~~~~~~~~~~~
local awful = require "awful"
local ruled = require "ruled"
local gears = require "gears"
local beautiful = require "beautiful"
-- connect to signal
ruled.client.connect_signal("request::rules", function()
-- All clients will match this rule.
ruled.client.append_rule {
id = "global",
rule = { },
properties = {
focus = awful.client.focus.filter,
raise = true,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap+awful.placement.no_offscreen+awful.placement.centered
}
}
-- Floating clients.
ruled.client.append_rule {
id = "floating",
rule_any = {
instance = { "copyq", "pinentry" },
class = {
"Arandr",
"Steam",
"XTerm",
"Virt-manager",
"VirtualBox Manager",
"Nm-connection-editor",
"Xfce4-power-manager-settings",
"Pavucontrol",
"Qalculate-gtk",
"Engrampa",
"Lxappearance",
"Gnome-disks",
"Nitrogen",
"Audacious",
"qt5ct",
"qt6ct",
"Kvantum Manager",
"Blueman-manager",
"Gpick",
"Kruler",
"MessageWin", -- kalarm.
"Sxiv",
"Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
"Wpa_gui",
"veromix",
"alsamixer",
"xtightvncviewer",
"Gufw Firewall",
"VPN4Test"
},
-- Note that the name property shown in xprop might be set slightly after creation of the client
-- and the name shown there might not match defined rules here.
name = {
"Event Tester", -- xev.
},
role = {
"AlarmWindow", -- Thunderbird's calendar.
"ConfigManager", -- Thunderbird's about:config.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
}
},
properties = { floating = true }
}
-- Center Placement
ruled.client.append_rule {
id = "center_placement",
rule_any = {
type = {"dialog"},
class = {"Steam", "discord", "markdown_input", "nemo", "thunar", "pcmanfm" },
instance = {"markdown_input",},
role = {"GtkFileChooserDialog"}
},
properties = {placement = awful.placement.center}
}
-- Add titlebars to normal clients and dialogs
ruled.client.append_rule {
id = "titlebars",
rule_any = { type = { "normal", "dialog" } },
properties = { titlebars_enabled = true }
}
-- Set Firefox to always map on the tag named "2" on screen 1.
-- ruled.client.append_rule {
-- rule = { class = "Firefox" },
-- properties = { screen = 1, tag = "2" }
-- }
end)
ruled.notification.connect_signal('request::rules', function()
-- All notifications will match this rule.
ruled.notification.append_rule {
rule = { },
properties = {
screen = awful.screen.preferred,
implicit_timeout = 5,
position = "top_right",
}
}
end)
-- Vbox Fix :
client.disconnect_signal("request::geometry", awful.ewmh.client_geometry_requests)
-- Master-Slave layout new client goes to the slave, master is kept
client.connect_signal("manage", function(c)
-- Similar behavior as other window managers DWM, XMonad.
-- If you need new slave as master press: ctrl + super + return
if not awesome.startup then awful.client.setslave(c) end
end)
-- Window opacity
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
c.opacity = 1
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
c.opacity = 0.99
end)
-- Round Corners :
--client.connect_signal("manage", function (c)
-- c.shape = function(cr,w,h)
-- gears.shape.rounded_rect(cr,w,h,8)
-- end
--end)

View file

@ -1,24 +0,0 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
trim_trailing_whitespace = true
[*.lua]
indent_size = 4
indent_style = space
max_line_length = 80
[*.yml]
indent_size = 2
indent_style = space
[*.{html,css}]
indent_size = 2
indent_style = space
[*.md]
trim_trailing_whitespace = false

View file

@ -1,10 +0,0 @@
The following developers have contributed major code to bling:
* [Nooo37](https://github.com/Nooo37)
* [JavaCafe01](https://github.com/JavaCafe01)
* [Grumph](https://github.com/Grumph)
* [Bysmutheye](https://github.com/Bysmutheye)
* [HumblePresent](https://github.com/HumblePresent)
* [Kasper24](https://github.com/Kasper24)
* [undefinedDarkness](https://github.com/undefinedDarkness)
* [eylles](https://github.com/eylles)

View file

@ -1,2 +0,0 @@
/module/* @Nooo37
/widget/* @JavaCafe01

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 BlingCorp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,41 +0,0 @@
<p align="center">
<img src="/images/bling_banner.png" />
</p>
<h1 align="center"></h1>
All documentation, instructions, and previews are [here](https://blingcorp.github.io/bling/).
## Features
- Layouts
- mstab (master-slave tab layout)
- centered
- vertical
- horizontal
- equalarea
- Modules
- Flash Focus
- Tabbed container
- Tiled Wallpaper
- Wallpaper Easy Setup
- Window Swallowing
- Scratchpad
- Signals
- Playerctl
- Widgets
- Tag Preview
- Task Preview
All naming credit goes to [JavaCafe01](https://github.com/JavaCafe01).
### Dependencies
In order to use the `tabbed` modules `pick` function, you need to install `xwininfo`.
## Contributing
Contributions are welcome 💛
Before requesting changes, makes sure that your editor has an "editorconfig" extension installed, this will use our code style everytime when you edit in the `bling` folder.
When adding a layout/module/signal/widget, please add theme variables for customization and add the according documentation under `docs`.

View file

@ -1,63 +0,0 @@
package = "bling"
version = "dev-1"
source = {
url = "git://github.com/BlingCorp/bling",
branch = "master",
}
description = {
summary = "Utilities for the AwesomeWM",
detailed = [[
This module extends the Awesome window manager with alternative layouts,
flash focus, tabbing, a simple tiling wallpaper generator, a declarative
wallpaper setter, window swallowing and a playerctl signal.
]],
homepage = "https://github.com/BlingCorp/bling",
license = "MIT",
}
dependencies = {
"lua >= 5.1",
}
build = {
type = "builtin",
modules = {
["bling"] = "init.lua",
["bling.helpers"] = "helpers/init.lua",
["bling.helpers.client"] = "helpers/client.lua",
["bling.helpers.color"] = "helpers/color.lua",
["bling.helpers.filesystem"] = "helpers/filesystem.lua",
["bling.helpers.shape"] = "helpers/shape.lua",
["bling.helpers.time"] = "helpers/time.lua",
["bling.layout"] = "layout/init.lua",
["bling.layout.centered"] = "layout/centered.lua",
["bling.layout.deck"] = "layout/deck.lua",
["bling.layout.equalarea"] = "layout/equalarea.lua",
["bling.layout.horizontal"] = "layout/horizontal.lua",
["bling.layout.mstab"] = "layout/mstab.lua",
["bling.layout.vertical"] = "layout/vertical.lua",
["bling.module"] = "module/init.lua",
["bling.module.flash_focus"] = "module/flash_focus.lua",
["bling.module.scratchpad"] = "module/scratchpad.lua",
["bling.module.tabbed"] = "module/tabbed.lua",
["bling.module.tiled_wallpaper"] = "module/tiled_wallpaper.lua",
["bling.module.wallpaper"] = "module/wallpaper.lua",
["bling.module.window_swallowing"] = "module/window_swallowing.lua",
["bling.signal"] = "signal/init.lua",
["bling.signal.playerctl"] = "signal/playerctl/init.lua",
["bling.signal.playerctl.playerctl_cli"] = "signal/playerctl/playerctl_cli.lua",
["bling.signal.playerctl.playerctl_lib"] = "signal/playerctl/playerctl_lib.lua",
["bling.widget"] = "widget/init.lua",
["bling.widget.tabbar.boxes"] = "widget/tabbar/boxes.lua",
["bling.widget.tabbar.default"] = "widget/tabbar/default.lua",
["bling.widget.tabbar.modern"] = "widget/tabbar/modern.lua",
["bling.widget.tabbed_misc"] = "widget/tabbed_misc/init.lua",
["bling.widget.tabbed_misc.custom_tasklist"] = "widget/tabbed_misc/custom_tasklist.lua",
["bling.widget.tabbed_misc.titlebar_indicator"] = "widget/tabbed_misc/titlebar_indicator.lua",
["bling.widget.tag_preview"] = "widget/tag_preview.lua",
["bling.widget.task_preview"] = "widget/task_preview.lua",
["bling.widget.window_switcher"] = "widget/window_switcher.lua",
},
}

View file

@ -1,23 +0,0 @@
- [Home](home.md)
- [Layouts](layouts/layout.md)
- Modules
- [Flash Focus](module/flash.md)
- [Tabbed](module/tabbed.md)
- [Tiled Wallpaper](module/twall.md)
- [Wallpaper Easy Setup](module/wall.md)
- [Window Swallowing](module/swal.md)
- [Scratchpad](module/scratch.md)
- Signals
- [Playerctl](signals/pctl.md)
- Widgets
- [Tag Preview](widgets/tag_preview.md)
- [Task Preview](widgets/task_preview.md)
- [Tabbed Misc](widgets/tabbed_misc.md)
- [Window Switcher](widgets/window_switcher.md)
- Extra
- [Theme Variable Template](theme.md)

View file

@ -1,34 +0,0 @@
# <center> 🌟 Bling - Utilities for AwesomeWM 🌟 </center>
## Why
[AwesomeWM](https://awesomewm.org/) is literally what it stands for, an awesome window manager.
Its unique selling point has always been the widget system, which allows for fancy buttons, sliders, bars, dashboards and anything you can imagine. But that feature can be a curse. Most modules focus on the widget side of things which leave the actual window managing part of AwesomeWM underdeveloped compared to, for example, [xmonad](https://xmonad.org/) even though it's probably just as powerfull in that area.
This project focuses on that problem - adding new layouts and modules that make use of the widget system, but primarily focus on the new window managing features.
## Installation
- clone this repo into your `~/.config/awesome` folder
- `git clone https://github.com/BlingCorp/bling.git ~/.config/awesome/bling`
- require the module in your `rc.lua`, and make sure it's under the beautiful module initialization
```lua
-- other imports
local beautiful = require("beautiful")
-- other configuration stuff here
beautiful.init("some_theme.lua")
local bling = require("bling")
```
## Contributors
A special thanks to all our contributors...
<a href="https://github.com/BlingCorp/bling/graphs/contributors">
<img src="https://contrib.rocks/image?repo=BlingCorp/bling" />
</a>
Made with [contributors-img](https://contrib.rocks).

View file

@ -1,28 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bling Docs</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Utilities for the awesome window manager">
<meta name="og:image" content="https://raw.githubusercontent.com/BlingCorp/bling/master/images/bling_banner.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="javacafe.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'Bling',
nameLink: '/',
repo: 'https://github.com/BlingCorp/bling',
loadSidebar: true,
subMaxLevel: 3,
homepage: 'home.md'
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//unpkg.com/prismjs/components/prism-lua.js"></script>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -1,65 +0,0 @@
## 📎 Layouts <!-- {docsify-ignore} -->
Choose layouts from the list below and add them to to your `awful.layouts` list in your `rc.lua`.
Everyone of them supports multiple master clients and master width factor making them easy to use.
The mstab layout uses the tab theme from the tabbed module.
```lua
bling.layout.mstab
bling.layout.centered
bling.layout.vertical
bling.layout.horizontal
bling.layout.equalarea
bling.layout.deck
```
### Theme Variables
```lua
-- mstab
theme.mstab_bar_disable = false -- disable the tabbar
theme.mstab_bar_ontop = false -- whether you want to allow the bar to be ontop of clients
theme.mstab_dont_resize_slaves = false -- whether the tabbed stack windows should be smaller than the
-- currently focused stack window (set it to true if you use
-- transparent terminals. False if you use shadows on solid ones
theme.mstab_bar_padding = "default" -- how much padding there should be between clients and your tabbar
-- by default it will adjust based on your useless gaps.
-- If you want a custom value. Set it to the number of pixels (int)
theme.mstab_border_radius = 0 -- border radius of the tabbar
theme.mstab_bar_height = 40 -- height of the tabbar
theme.mstab_tabbar_position = "top" -- position of the tabbar (mstab currently does not support left,right)
theme.mstab_tabbar_style = "default" -- style of the tabbar ("default", "boxes" or "modern")
-- defaults to the tabbar_style so only change if you want a
-- different style for mstab and tabbed
```
### Previews
#### Mstab (dynamic tabbing layout)
![](https://imgur.com/HZRgApE.png)
*screenshot by [JavaCafe01](https://github.com/JavaCafe01)*
#### Centered
![](https://media.discordapp.net/attachments/769673106842845194/780095998239834142/unknown.png)
*screenshot by [HeavyRain266](https://github.com/HeavyRain266)*
#### Equal area
![](https://imgur.com/JCFFywv.png)
*screenshot by [bysmutheye](https://github.com/bysmutheye)*
#### Deck
The left area shows the deck layout in action. In this screenshot it is used together with [layout machi](https://github.com/xinhaoyuan/layout-machi) and its sublayout support.
![](https://cdn.discordapp.com/attachments/635625954219261982/877957824225894430/unknown.png)
*screenshot by [JavaCafe01](https://github.com/JavaCafe01)*

View file

@ -1,33 +0,0 @@
## 🔦 Flash Focus <!-- {docsify-ignore} -->
Flash focus does an opacity animation effect on a client when it is focused.
### Usage
There are two ways in which you can use this module. You can enable it by calling the `enable()` function:
```lua
bling.module.flash_focus.enable()
```
This connects to the focus signal of a client, which means that the flash focus will activate however you focus the client.
The other way is to call the function itself like this: `bling.module.flash_focus.flashfocus(someclient)`. This allows you to activate on certain keybinds like so:
```lua
awful.key({modkey}, "Up",
function()
awful.client.focus.bydirection("up")
bling.module.flash_focus.flashfocus(client.focus)
end, {description = "focus up", group = "client"})
```
### Theme Variables
```lua
theme.flash_focus_start_opacity = 0.6 -- the starting opacity
theme.flash_focus_step = 0.01 -- the step of animation
```
### Preview
![](https://imgur.com/5txYrlV.gif)
*gif by [JavaCafe01](https://github.com/JavaCafe01)*

View file

@ -1,75 +0,0 @@
## 🍃 Scratchpad <!-- {docsify-ignore} -->
An easy way to create multiple scratchpads.
### A... what?
You can think about a scratchpad as a window whose visibility can be toggled, but still runs in the background without being visible (or minimized) most of the time. Many people use it to have one terminal in which to perform minor tasks, but it is the most useful for windows which only need a couple seconds in between your actual activity, such as music players or chat applications.
### Rubato Animation Support
#### Awestore is now deprecated from Bling, we are switching to Rubato.
Please go over to the [rubato](https://github.com/andOrlando/rubato) repository for installation instructions. Give it a star as well! The animations are completely optional, and if you choose not to use it, you do not need rubato installed.
### Usage
To initalize a scratchpad you can do something like the following:
```lua
local bling = require("bling")
local rubato = require("rubato") -- Totally optional, only required if you are using animations.
-- These are example rubato tables. You can use one for just y, just x, or both.
-- The duration and easing is up to you. Please check out the rubato docs to learn more.
local anim_y = rubato.timed {
pos = 1090,
rate = 60,
easing = rubato.quadratic,
intro = 0.1,
duration = 0.3,
awestore_compat = true -- This option must be set to true.
}
local anim_x = rubato.timed {
pos = -970,
rate = 60,
easing = rubato.quadratic,
intro = 0.1,
duration = 0.3,
awestore_compat = true -- This option must be set to true.
}
local term_scratch = bling.module.scratchpad {
command = "wezterm start --class spad", -- How to spawn the scratchpad
rule = { instance = "spad" }, -- The rule that the scratchpad will be searched by
sticky = true, -- Whether the scratchpad should be sticky
autoclose = true, -- Whether it should hide itself when losing focus
floating = true, -- Whether it should be floating (MUST BE TRUE FOR ANIMATIONS)
geometry = {x=360, y=90, height=900, width=1200}, -- The geometry in a floating state
reapply = true, -- Whether all those properties should be reapplied on every new opening of the scratchpad (MUST BE TRUE FOR ANIMATIONS)
dont_focus_before_close = false, -- When set to true, the scratchpad will be closed by the toggle function regardless of whether its focused or not. When set to false, the toggle function will first bring the scratchpad into focus and only close it on a second call
rubato = {x = anim_x, y = anim_y} -- Optional. This is how you can pass in the rubato tables for animations. If you don't want animations, you can ignore this option.
}
```
Once initalized, you can use the object (which in this case is named `term_scratch`) like this:
```lua
term_scratch:toggle() -- toggles the scratchpads visibility
term_scratch:turn_on() -- turns the scratchpads visibility on
term_scratch:turn_off() -- turns the scratchpads visibility off
```
You can also connect to signals as you are used to for further customization. For example like that:
```lua
term_scratch:connect_signal("turn_on", function(c) naughty.notify({title = "Turned on!"}) end)
```
The following signals are currently available. `turn_on`, `turn_off` and `inital_apply` pass the client on which they operated as an argument:
- `turn_on` fires when the scratchpad is turned on on a tag that it wasn't present on before
- `turn_off` fires when the scratchpad is turned off on a tag
- `spawn` fires when the scratchpad is launched with the given command
- `inital_apply` fires after `spawn`, when a corresponding client has been found and the properties have been applied

View file

@ -1,25 +0,0 @@
## 😋 Window Swallowing <!-- {docsify-ignore} -->
Can your window manager swallow? It probably can...
### Usage
To activate and deactivate window swallowing here are the following functions. If you want to activate it, just call the `start` function once in your `rc.lua`.
```lua
bling.module.window_swallowing.start() -- activates window swallowing
bling.module.window_swallowing.stop() -- deactivates window swallowing
bling.module.window_swallowing.toggle() -- toggles window swallowing
```
### Theme Variables
```lua
theme.parent_filter_list = {"firefox", "Gimp"} -- class names list of parents that should not be swallowed
theme.child_filter_list = { "Dragon" } -- class names list that should not swallow their parents
theme.swallowing_filter = true -- whether the filters above should be active
```
### Preview
![](https://media.discordapp.net/attachments/635625813143978012/769180910683684864/20-10-23-14-40-32.gif)
*gif by [Nooo37](https://github.com/Nooo37)*

View file

@ -1,66 +0,0 @@
## 📑 Tabbed <!-- {docsify-ignore} -->
Tabbed implements a tab container. There are also different themes for the tabs.
### Usage
You should bind these functions to keys in order to use the tabbed module effectively:
```lua
bling.module.tabbed.pick() -- picks a client with your cursor to add to the tabbing group
bling.module.tabbed.pop() -- removes the focused client from the tabbing group
bling.module.tabbed.iter() -- iterates through the currently focused tabbing group
bling.module.tabbed.pick_with_dmenu() -- picks a client with a dmenu application (defaults to rofi, other options can be set with a string parameter like "dmenu")
bling.module.tabbed.pick_by_direction(dir) -- picks a client based on direction ("up", "down", "left" or "right")
```
### Theme Variables
```lua
-- For tabbed only
theme.tabbed_spawn_in_tab = false -- whether a new client should spawn into the focused tabbing container
-- For tabbar in general
theme.tabbar_ontop = false
theme.tabbar_radius = 0 -- border radius of the tabbar
theme.tabbar_style = "default" -- style of the tabbar ("default", "boxes" or "modern")
theme.tabbar_font = "Sans 11" -- font of the tabbar
theme.tabbar_size = 40 -- size of the tabbar
theme.tabbar_position = "top" -- position of the tabbar
theme.tabbar_bg_normal = "#000000" -- background color of the focused client on the tabbar
theme.tabbar_fg_normal = "#ffffff" -- foreground color of the focused client on the tabbar
theme.tabbar_bg_focus = "#1A2026" -- background color of unfocused clients on the tabbar
theme.tabbar_fg_focus = "#ff0000" -- foreground color of unfocused clients on the tabbar
theme.tabbar_bg_focus_inactive = nil -- background color of the focused client on the tabbar when inactive
theme.tabbar_fg_focus_inactive = nil -- foreground color of the focused client on the tabbar when inactive
theme.tabbar_bg_normal_inactive = nil -- background color of unfocused clients on the tabbar when inactive
theme.tabbar_fg_normal_inactive = nil -- foreground color of unfocused clients on the tabbar when inactive
theme.tabbar_disable = false -- disable the tab bar entirely
-- the following variables are currently only for the "modern" tabbar style
theme.tabbar_color_close = "#f9929b" -- chnges the color of the close button
theme.tabbar_color_min = "#fbdf90" -- chnges the color of the minimize button
theme.tabbar_color_float = "#ccaced" -- chnges the color of the float button
```
### Preview
Modern theme:
<img src="https://imgur.com/omowmIQ.png" width="600"/>
*screenshot by [JavaCafe01](https://github.com/JavaCafe01)*
### Signals
The tabbed module emits a few signals for the purpose of integration,
```lua
-- bling::tabbed::update -- triggered whenever a tabbed object is updated
-- tabobj -- the object that caused the update
-- bling::tabbed::client_added -- triggered whenever a new client is added to a tab group
-- tabobj -- the object that the client was added to
-- client -- the client that added
-- bling::tabbed::client_removed -- triggered whenever a client is removed from a tab group
-- tabobj -- the object that the client was removed from
-- client -- the client that was removed
-- bling::tabbed::changed_focus -- triggered whenever a tab group's focus is changed
-- tabobj -- the modified tab group
```

View file

@ -1,26 +0,0 @@
## 🏬 Tiled Wallpaper <!-- {docsify-ignore} -->
### Usage
The function to set an automatically created tiled wallpaper can be called the following way (you don't need to set every option in the table):
```lua
awful.screen.connect_for_each_screen(function(s) -- that way the wallpaper is applied to every screen
bling.module.tiled_wallpaper("x", s, { -- call the actual function ("x" is the string that will be tiled)
fg = "#ff0000", -- define the foreground color
bg = "#00ffff", -- define the background color
offset_y = 25, -- set a y offset
offset_x = 25, -- set a x offset
font = "Hack", -- set the font (without the size)
font_size = 14, -- set the font size
padding = 100, -- set padding (default is 100)
zickzack = true -- rectangular pattern or criss cross
})
end)
```
### Preview
![](https://media.discordapp.net/attachments/702548913999314964/773887721294135296/tiled-wallpapers.png?width=1920&height=1080)
*screenshots by [Nooo37](https://github.com/Nooo37)*

View file

@ -1,142 +0,0 @@
## 🎇 Wallpaper Easy Setup <!-- {docsify-ignore} -->
This is a simple-to-use, extensible, declarative wallpaper manager.
### Practical Examples
```lua
-- A default Awesome wallpaper
bling.module.wallpaper.setup()
-- A slideshow with pictures from different sources changing every 30 minutes
bling.module.wallpaper.setup {
wallpaper = {"/images/my_dog.jpg", "/images/my_cat.jpg"},
change_timer = 1800
}
-- A random wallpaper with images from multiple folders
bling.module.wallpaper.setup {
set_function = bling.module.wallpaper.setters.random,
wallpaper = {"/path/to/a/folder", "/path/to/another/folder"},
change_timer = 631, -- prime numbers are better for timers
position = "fit",
background = "#424242"
}
-- wallpapers based on a schedule, like awesome-glorious-widgets dynamic wallpaper
-- https://github.com/manilarome/awesome-glorious-widgets/tree/master/dynamic-wallpaper
bling.module.wallpaper.setup {
set_function = bling.module.wallpaper.setters.simple_schedule,
wallpaper = {
["06:22:00"] = "morning-wallpaper.jpg",
["12:00:00"] = "noon-wallpaper.jpg",
["17:58:00"] = "night-wallpaper.jpg",
["24:00:00"] = "midnight-wallpaper.jpg",
},
position = "maximized",
}
-- random wallpapers, from different folder depending on time of the day
bling.module.wallpaper.setup {
set_function = bling.module.wallpaper.setters.simple_schedule,
wallpaper = {
["09:00:00"] = "~/Pictures/safe_for_work",
["18:00:00"] = "~/Pictures/personal",
},
schedule_set_function = bling.module.wallpaper.setters.random
position = "maximized",
recursive = false,
change_timer = 600
}
-- setup for multiple screens at once
-- the 'screen' argument can be a table of screen objects
bling.module.wallpaper.setup {
set_function = bling.module.wallpaper.setters.random,
screen = screen, -- The awesome 'screen' variable is an array of all screen objects
wallpaper = {"/path/to/a/folder", "/path/to/another/folder"},
change_timer = 631
}
```
### Details
The setup function will do 2 things: call the set-function when awesome requests a wallpaper, and manage a timer to call `set_function` periodically.
Its argument is a args table that is passed to ohter functions (setters and wallpaper functions), so you define everything with setup.
The `set_function` is a function called every times a wallpaper is needed.
The module provides some setters:
* `bling.module.wallpaper.setters.awesome_wallpaper`: beautiful.theme_assets.wallpaper with defaults from beautiful.
* `bling.module.wallpaper.setters.simple`: slideshow from the `wallpaper` argument.
* `bling.module.wallpaper.setters.random`: same as simple but in a random way.
* `bling.module.wallpaper.setters.simple_schedule`: takes a table of `["HH:MM:SS"] = wallpaper` arguments, where wallpaper is the `wallpaper` argument used by `schedule_set_function`.
A wallpaper is one of the following elements:
* a color
* an image
* a folder containing images
* a function that sets a wallpaper
* everything gears.wallpaper functions can manage (cairo surface, cairo pattern string)
* a list containing any of the elements above
To set up for multiple screens, two possible methods are:
* Call the `setup` function for each screen, passing the appropriate configuration and `screen` arg
* Call the `setup` function once, passing a table of screens as the `screen` arg. This applies the same configuration to all screens in the table
_Note_: Multiple screen setup only works for the `simple` and `random` setters
```lua
-- This is a valid wallpaper definition
bling.module.wallpaper.setup {
wallpaper = { -- a list
"black", "#112233", -- colors
"wall1.jpg", "wall2.png", -- files
"/path/to/wallpapers", -- folders
-- cairo patterns
"radial:600,50,100:105,550,900:0,#2200ff:0.5,#00ff00:1,#101010",
-- or functions that set a wallpaper
function(args) bling.module.tiled_wallpaper("\\o/", args.screen) end,
bling.module.wallpaper.setters.awesome_wallpaper,
},
change_timer = 10,
}
```
The provided setters `simple` and `random` will use 2 internal functions that you can use to write your own setter:
* `bling.module.wallpaper.prepare_list`: return a list of wallpapers directly usable by `apply` (for now, it just explores folders)
* `bling.module.wallpaper.apply`: a wrapper for gears.wallpaper functions, using the args table of setup
Here are the defaults:
```lua
-- Default parameters
bling.module.wallpaper.setup {
screen = nil, -- the screen to apply the wallpaper, as seen in gears.wallpaper functions
screens = nil, -- an array of screens to apply the wallpaper on. If 'screen' is also provided, this is overridden
change_timer = nil, -- the timer in seconds. If set, call the set_function every change_timer seconds
set_function = nil, -- the setter function
-- parameters used by bling.module.wallpaper.prepare_list
wallpaper = nil, -- the wallpaper object, see simple or simple_schedule documentation
image_formats = {"jpg", "jpeg", "png", "bmp"}, -- when searching in folder, consider these files only
recursive = true, -- when searching in folder, search also in subfolders
-- parameters used by bling.module.wallpaper.apply
position = nil, -- use a function of gears.wallpaper when applicable ("centered", "fit", "maximized", "tiled")
background = beautiful.bg_normal or "black", -- see gears.wallpaper functions
ignore_aspect = false, -- see gears.wallpaper.maximized
offset = {x = 0, y = 0}, -- see gears.wallpaper functions
scale = 1, -- see gears.wallpaper.centered
-- parameters that only apply to bling.module.wallpaper.setter.awesome (as a setter or as a wallpaper function)
colors = { -- see beautiful.theme_assets.wallpaper
bg = beautiful.bg_color, -- the actual default is this color but darkened or lightned
fg = beautiful.fg_color,
alt_fg = beautiful.fg_focus
}
}
```
Check documentation in [module/wallpaper.lua](module/wallpaper.lua) for more details.

View file

@ -1,240 +0,0 @@
## 🎵 Playerctl <!-- {docsify-ignore} -->
This is a signal module in which you can connect to certain bling signals to grab playerctl info. Currently, this is what it supports:
- Song title and artist
- Album art (the path this module downloaded the art to)
- If playing or not
- Position
- Song length
- If there are no players on
This module relies on `playerctl` and `curl`. If you have this module disabled, you won't need those programs. With this module, you can create a widget like below without worrying about the backend.
![](https://user-images.githubusercontent.com/33443763/107377569-fa807900-6a9f-11eb-93c1-174c58eb7bf1.png)
*screenshot by [javacafe](https://github.com/JavaCafe01)*
### Usage
To enable: `playerctl = bling.signal.playerctl.lib/cli()`
To disable: `playerctl:disable()`
#### Playerctl_lib Signals
**Note**: When connecting to signals with the new `playerctl` module, the object itself is always given to you as the first parameter.
```lua
-- metadata
-- title (string)
-- artist (string)
-- album_path (string)
-- album (string)
-- new (bool)
-- player_name (string)
-- position
-- interval_sec (number)
-- length_sec (number)
-- player_name (string)
-- playback_status
-- playing (boolean)
-- player_name (string)
-- seeked
-- position (number)
-- player_name (string)
-- volume
-- volume (number)
-- player_name (string)
-- loop_status
-- loop_status (string)
-- player_name (string)
-- shuffle
-- shuffle (boolean)
-- player_name (string)
-- exit
-- player_name (string)
-- no_players
-- (No parameters)
```
#### Playerctl_cli Signals
```lua
-- metadata
-- title (string)
-- artist (string)
-- album_path (string)
-- album (string)
-- player_name (string)
-- position
-- interval_sec (number)
-- length_sec (number)
-- playback_status
-- playing (boolean)
-- volume
-- volume (number)
-- loop_status
-- loop_status (string)
-- shuffle
-- shuffle (bool)
-- no_players
-- (No parameters)
```
#### Playerctl Functions
With this library we also give the user a way to interact with Playerctl, such as playing, pausing, seeking, etc.
Here are the functions provided:
```lua
-- disable()
-- pause(player)
-- play(player)
-- stop(player)
-- play_pause(player)
-- previous(player)
-- next(player)
-- set_loop_status(loop_status, player)
-- cycle_loop_status(player)
-- set_position(position, player)
-- set_shuffle(shuffle, player)
-- cycle_shuffle(player)
-- set_volume(volume, player)
-- get_manager()
-- get_active_player()
-- get_player_of_name(name)
```
### Example Implementation
Lets say we have an imagebox. If I wanted to set the imagebox to show the album art, all I have to do is this:
```lua
local art = wibox.widget {
image = "default_image.png",
resize = true,
forced_height = dpi(80),
forced_width = dpi(80),
widget = wibox.widget.imagebox
}
local name_widget = wibox.widget {
markup = 'No players',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
local title_widget = wibox.widget {
markup = 'Nothing Playing',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
local artist_widget = wibox.widget {
markup = 'Nothing Playing',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
}
-- Get Song Info
local playerctl = bling.signal.playerctl.lib()
playerctl:connect_signal("metadata",
function(_, title, artist, album_path, album, new, player_name)
-- Set art widget
art:set_image(gears.surface.load_uncached(album_path))
-- Set player name, title and artist widgets
name_widget:set_markup_silently(player_name)
title_widget:set_markup_silently(title)
artist_widget:set_markup_silently(artist)
end)
```
Thats all! You don't even have to worry about updating the widgets, the signals will handle that for you.
Here's another example in which you get a notification with the album art, title, and artist whenever the song changes.
```lua
local naughty = require("naughty")
local playerctl = bling.signal.playerctl.lib()
playerctl:connect_signal("metadata",
function(_, title, artist, album_path, album, new, player_name)
if new == true then
naughty.notify({title = title, text = artist, image = album_path})
end
end)
```
We can also link a playerctl function to a button click!
```lua
local playerctl = bling.signal.playerctl.lib()
button:buttons(gears.table.join(
awful.button({}, 1, function()
playerctl:play_pause()
end)
))
```
### Theme Variables and Configuration
By default, this module will output signals from the most recently active player. If you wish to customize the behavior furthur, the following configuration options are available depending on the selected backend. Here is a summary of the two backends and which configuration options they support.
| Option | playerctl_cli | playerctl_lib |
| ------------------- | ------------------ | ------------------ |
| ignore | :heavy_check_mark: | :heavy_check_mark: |
| player | :heavy_check_mark: | :heavy_check_mark: |
| update_on_activity | | :heavy_check_mark: |
| interval | :heavy_check_mark: | :heavy_check_mark: |
| debounce_delay | :heavy_check_mark: | :heavy_check_mark: |
- `ignore`: This option is either a string with a single name or a table of strings containing names of players that will be ignored by this module. It is empty by default.
- `player`: This option is either a string with a single name or a table of strings containing names of players this module will emit signals for. It also acts as a way to prioritize certain players over others with players listed earlier in the table being preferred over players listed later. The special name `%any` can be used once to match any player not found in the list. It is empty by default.
- `update_on_activity`: This option is a boolean that, when true, will cause the module to output signals from the most recently active player while still adhering to the player priority specified with the `player` option. If `false`, the module will output signals from the player that started first, again, while still adhering to the player priority. It is `true` by default.
- `interval`: This option is a number specifying the update interval for fetching the player position. It is 1 by default.
- `debounce_delay`: This option is a number specifying the debounce timer interval. If a new metadata signal gets emitted before debounce_delay has passed, the last signal will be dropped.
This is to help with some players sending multiple signals. It is `0.35` by default.
These options can be set through a call to `bling.signal.playerctl.lib/cli()` or these theme variables:
```lua
theme.playerctl_ignore = {}
theme.playerctl_player = {}
theme.playerctl_update_on_activity = true
theme.playerctl_position_update_interval = 1
```
#### Example Configurations
```lua
-- Prioritize ncspot over all other players and ignore firefox players (e.g. YouTube and Twitch tabs) completely
playerctl = bling.signal.playerctl.lib {
ignore = "firefox",
player = {"ncspot", "%any"}
}
-- OR in your theme file:
-- Same config as above but with theme variables
theme.playerctl_ignore = "firefox"
theme.playerctl_player = {"ncspot", "%any"}
-- Prioritize vlc over all other players and deprioritize spotify
theme.playerctl_backend = "playerctl_lib"
theme.playerctl_player = {"vlc", "%any", "spotify"}
-- Disable priority of most recently active players
theme.playerctl_update_on_activity = false
-- Only emit the position signal every 2 seconds
theme.playerctl_position_update_interval = 2
```

View file

@ -1,117 +0,0 @@
```lua
--[[ Bling theme variables template
This file has all theme variables of the bling module.
Every variable has a small comment on what it does.
You might just want to copy that whole part into your theme.lua and start adjusting from there.
--]]
-- window swallowing
theme.dont_swallow_classname_list = {"firefox", "Gimp"} -- list of class names that should not be swallowed
theme.dont_swallow_filter_activated = true -- whether the filter above should be active
-- flash focus
theme.flash_focus_start_opacity = 0.6 -- the starting opacity
theme.flash_focus_step = 0.01 -- the step of animation
-- playerctl signal
theme.playerctl_backend = "playerctl_cli" -- backend to use
theme.playerctl_ignore = {} -- list of players to be ignored
theme.playerctl_player = {} -- list of players to be used in priority order
theme.playerctl_update_on_activity = true -- whether to prioritize the most recently active players or not
theme.playerctl_position_update_interval = 1 -- the update interval for fetching the position from playerctl
-- tabbed
theme.tabbed_spawn_in_tab = false -- whether a new client should spawn into the focused tabbing container
-- tabbar general
theme.tabbar_ontop = false
theme.tabbar_radius = 0 -- border radius of the tabbar
theme.tabbar_style = "default" -- style of the tabbar ("default", "boxes" or "modern")
theme.tabbar_font = "Sans 11" -- font of the tabbar
theme.tabbar_size = 40 -- size of the tabbar
theme.tabbar_position = "top" -- position of the tabbar
theme.tabbar_bg_normal = "#000000" -- background color of the focused client on the tabbar
theme.tabbar_fg_normal = "#ffffff" -- foreground color of the focused client on the tabbar
theme.tabbar_bg_focus = "#1A2026" -- background color of unfocused clients on the tabbar
theme.tabbar_fg_focus = "#ff0000" -- foreground color of unfocused clients on the tabbar
theme.tabbar_bg_focus_inactive = nil -- background color of the focused client on the tabbar when inactive
theme.tabbar_fg_focus_inactive = nil -- foreground color of the focused client on the tabbar when inactive
theme.tabbar_bg_normal_inactive = nil -- background color of unfocused clients on the tabbar when inactive
theme.tabbar_fg_normal_inactive = nil -- foreground color of unfocused clients on the tabbar when inactive
theme.tabbar_disable = false -- disable the tab bar entirely
-- mstab
theme.mstab_bar_disable = false -- disable the tabbar
theme.mstab_bar_ontop = false -- whether you want to allow the bar to be ontop of clients
theme.mstab_dont_resize_slaves = false -- whether the tabbed stack windows should be smaller than the
-- currently focused stack window (set it to true if you use
-- transparent terminals. False if you use shadows on solid ones
theme.mstab_bar_padding = "default" -- how much padding there should be between clients and your tabbar
-- by default it will adjust based on your useless gaps.
-- If you want a custom value. Set it to the number of pixels (int)
theme.mstab_border_radius = 0 -- border radius of the tabbar
theme.mstab_bar_height = 40 -- height of the tabbar
theme.mstab_tabbar_position = "top" -- position of the tabbar (mstab currently does not support left,right)
theme.mstab_tabbar_style = "default" -- style of the tabbar ("default", "boxes" or "modern")
-- defaults to the tabbar_style so only change if you want a
-- different style for mstab and tabbed
-- the following variables are currently only for the "modern" tabbar style
theme.tabbar_color_close = "#f9929b" -- chnges the color of the close button
theme.tabbar_color_min = "#fbdf90" -- chnges the color of the minimize button
theme.tabbar_color_float = "#ccaced" -- chnges the color of the float button
-- tag preview widget
theme.tag_preview_widget_border_radius = 0 -- Border radius of the widget (With AA)
theme.tag_preview_client_border_radius = 0 -- Border radius of each client in the widget (With AA)
theme.tag_preview_client_opacity = 0.5 -- Opacity of each client
theme.tag_preview_client_bg = "#000000" -- The bg color of each client
theme.tag_preview_client_border_color = "#ffffff" -- The border color of each client
theme.tag_preview_client_border_width = 3 -- The border width of each client
theme.tag_preview_widget_bg = "#000000" -- The bg color of the widget
theme.tag_preview_widget_border_color = "#ffffff" -- The border color of the widget
theme.tag_preview_widget_border_width = 3 -- The border width of the widget
theme.tag_preview_widget_margin = 0 -- The margin of the widget
-- task preview widget
theme.task_preview_widget_border_radius = 0 -- Border radius of the widget (With AA)
theme.task_preview_widget_bg = "#000000" -- The bg color of the widget
theme.task_preview_widget_border_color = "#ffffff" -- The border color of the widget
theme.task_preview_widget_border_width = 3 -- The border width of the widget
theme.task_preview_widget_margin = 0 -- The margin of the widget
-- tabbed misc widget(s)
theme.bling_tabbed_misc_titlebar_indicator = {
layout_spacing = dpi(4),
icon_size = dpi(20),
icon_margin = dpi(4),
bg_color_focus = "#ff0000",
bg_color = "#00000000",
icon_shape = function(cr, w, h)
gears.shape.rounded_rect(cr, w, h, 0)
end,
layout = wibox.layout.fixed.horizontal
}
-- window switcher widget
theme.window_switcher_widget_bg = "#000000" -- The bg color of the widget
theme.window_switcher_widget_border_width = 3 -- The border width of the widget
theme.window_switcher_widget_border_radius = 0 -- The border radius of the widget
theme.window_switcher_widget_border_color = "#ffffff" -- The border color of the widget
theme.window_switcher_clients_spacing = 20 -- The space between each client item
theme.window_switcher_client_icon_horizontal_spacing = 5 -- The space between client icon and text
theme.window_switcher_client_width = 150 -- The width of one client widget
theme.window_switcher_client_height = 250 -- The height of one client widget
theme.window_switcher_client_margins = 10 -- The margin between the content and the border of the widget
theme.window_switcher_thumbnail_margins = 10 -- The margin between one client thumbnail and the rest of the widget
theme.thumbnail_scale = false -- If set to true, the thumbnails fit policy will be set to "fit" instead of "auto"
theme.window_switcher_name_margins = 10 -- The margin of one clients title to the rest of the widget
theme.window_switcher_name_valign = "center" -- How to vertically align one clients title
theme.window_switcher_name_forced_width = 200 -- The width of one title
theme.window_switcher_name_font = "sans 11" -- The font of all titles
theme.window_switcher_name_normal_color = "#ffffff" -- The color of one title if the client is unfocused
theme.window_switcher_name_focus_color = "#ff0000" -- The color of one title if the client is focused
theme.window_switcher_icon_valign = "center" -- How to vertically align the one icon
theme.window_switcher_icon_width = 40 -- The width of one icon
```

View file

@ -1,117 +0,0 @@
## 🧱 Tabbed Miscellaneous <!-- {docsify-ignore} -->
This comprises a few widgets to better represent tabbed groups (from the tabbed module) in your desktop.
The widgets currently included are:
- Titlebar Indicator
- Tasklist
![Preview Image](https://i.imgur.com/ZeYSrxY.png)
## Titlebar Indicator
### Usage
To use the task list indicator:
**NOTE:** Options can be set as theme vars under the table `theme.bling_tabbed_misc_titlebar_indicator`
```lua
bling.widget.tabbed_misc.titlebar_indicator(client, {
layout = wibox.layout.fixed.vertical,
layout_spacing = dpi(5), -- Set spacing in between items
icon_size = dpi(24), -- Set icon size
icon_margin = 0, -- Set icon margin
fg_color = "#cccccc", -- Normal color for text
fg_color_focus = "#ffffff", -- Color for focused text
bg_color_focus = "#282828", -- Color for the focused items
bg_color = "#1d2021", -- Color for normal / unfocused items
icon_shape = gears.shape.circle -- Set icon shape,
})
```
a widget_template option is also available:
```lua
bling.widget.tabbed_misc.titlebar_indicator(client, {
widget_template = {
{
widget = awful.widget.clienticon,
id = 'icon_role'
},
widget = wibox.container.margin,
margins = 2,
id = 'bg_role',
update_callback = function(self, client, group)
if client == group.clients[group.focused_idx] then
self.margins = 5
end
end
}
})
```
### Example Implementation
You normally embed the widget in your titlebar...
```lua
awful.titlebar(c).widget = {
{ -- Left
bling.widget.tabbed_misc.titlebar_indicator(c),
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
align = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal
},
layout = wibox.layout.align.horizontal
}
```
## Tasklist
The module exports a function that can be added to your tasklist as a `update_callback`
### Usage
```lua
awful.widget.tasklist({
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
layout = {
spacing = dpi(10),
layout = wibox.layout.fixed.vertical,
},
style = {
bg_normal = "#00000000",
},
widget_template = {
{
{
widget = wibox.widget.imagebox,
id = "icon_role",
align = "center",
valign = "center",
},
width = dpi(24),
height = dpi(24),
widget = wibox.container.constraint,
},
widget = wibox.container.background, -- IT MUST BE A CONTAINER WIDGET AS THAT IS WHAT THE FUNCTION EXPECTS
update_callback = require("bling.widget.tabbed_misc").custom_tasklist,
id = "background_role",
},
})
```
If you need to do something else, it can be used like so
```lua
update_callback = function(self, client, index, clients)
require("bling.widget.tabbed_misc").custom_tasklist(self, client, index, clients)
require("naughty").notify({ text = "Tasklist was updated" })
end
```

View file

@ -1,155 +0,0 @@
## 🔍 Tag Preview <!-- {docsify-ignore} -->
This is a popup widget that will show a preview of a specified tag that illustrates the position, size, content, and icon of all clients.
![](https://imgur.com/zFdvs4K.gif)
*gif by [javacafe](https://github.com/JavaCafe01)*
### Usage
To enable:
```lua
bling.widget.tag_preview.enable {
show_client_content = false, -- Whether or not to show the client content
x = 10, -- The x-coord of the popup
y = 10, -- The y-coord of the popup
scale = 0.25, -- The scale of the previews compared to the screen
honor_padding = false, -- Honor padding when creating widget size
honor_workarea = false, -- Honor work area when creating widget size
placement_fn = function(c) -- Place the widget using awful.placement (this overrides x & y)
awful.placement.top_left(c, {
margins = {
top = 30,
left = 30
}
})
end,
background_widget = wibox.widget { -- Set a background image (like a wallpaper) for the widget
image = beautiful.wallpaper,
horizontal_fit_policy = "fit",
vertical_fit_policy = "fit",
widget = wibox.widget.imagebox
}
}
```
Here are the signals available:
```lua
-- bling::tag_preview::update -- first line is the signal
-- t (tag) -- indented lines are function parameters
-- bling::tag_preview::visibility
-- s (screen)
-- v (boolean)
```
By default, the widget is not visible. You must implement when it will update and when it will show.
### Example Implementation
We can trigger the widget to show the specific tag when hovering over it in the taglist. The code shown below is the example taglist from the [AwesomeWM docs](https://awesomewm.org/doc/api/classes/awful.widget.taglist.html). Basically, we are going to update the widget and toggle it through the taglist's `create_callback`. (The bling addons are commented)
```lua
s.mytaglist = awful.widget.taglist {
screen = s,
filter = awful.widget.taglist.filter.all,
style = {
shape = gears.shape.powerline
},
layout = {
spacing = -12,
spacing_widget = {
color = '#dddddd',
shape = gears.shape.powerline,
widget = wibox.widget.separator,
},
layout = wibox.layout.fixed.horizontal
},
widget_template = {
{
{
{
{
{
id = 'index_role',
widget = wibox.widget.textbox,
},
margins = 4,
widget = wibox.container.margin,
},
bg = '#dddddd',
shape = gears.shape.circle,
widget = wibox.container.background,
},
{
{
id = 'icon_role',
widget = wibox.widget.imagebox,
},
margins = 2,
widget = wibox.container.margin,
},
{
id = 'text_role',
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.horizontal,
},
left = 18,
right = 18,
widget = wibox.container.margin
},
id = 'background_role',
widget = wibox.container.background,
-- Add support for hover colors and an index label
create_callback = function(self, c3, index, objects) --luacheck: no unused args
self:get_children_by_id('index_role')[1].markup = '<b> '..index..' </b>'
self:connect_signal('mouse::enter', function()
-- BLING: Only show widget when there are clients in the tag
if #c3:clients() > 0 then
-- BLING: Update the widget with the new tag
awesome.emit_signal("bling::tag_preview::update", c3)
-- BLING: Show the widget
awesome.emit_signal("bling::tag_preview::visibility", s, true)
end
if self.bg ~= '#ff0000' then
self.backup = self.bg
self.has_backup = true
end
self.bg = '#ff0000'
end)
self:connect_signal('mouse::leave', function()
-- BLING: Turn the widget off
awesome.emit_signal("bling::tag_preview::visibility", s, false)
if self.has_backup then self.bg = self.backup end
end)
end,
update_callback = function(self, c3, index, objects) --luacheck: no unused args
self:get_children_by_id('index_role')[1].markup = '<b> '..index..' </b>'
end,
},
buttons = taglist_buttons
}
```
### Theme Variables
```lua
theme.tag_preview_widget_border_radius = 0 -- Border radius of the widget (With AA)
theme.tag_preview_client_border_radius = 0 -- Border radius of each client in the widget (With AA)
theme.tag_preview_client_opacity = 0.5 -- Opacity of each client
theme.tag_preview_client_bg = "#000000" -- The bg color of each client
theme.tag_preview_client_border_color = "#ffffff" -- The border color of each client
theme.tag_preview_client_border_width = 3 -- The border width of each client
theme.tag_preview_widget_bg = "#000000" -- The bg color of the widget
theme.tag_preview_widget_border_color = "#ffffff" -- The border color of the widget
theme.tag_preview_widget_border_width = 3 -- The border width of the widget
theme.tag_preview_widget_margin = 0 -- The margin of the widget
```
NOTE: I recommend to only use the widget border radius theme variable when not using shadows with a compositor, as anti-aliased rounding with the outer widgets made with AwesomeWM rely on the actual bg being transparent. If you want rounding with shadows on the widget, use a compositor like [jonaburg's fork](https://github.com/jonaburg/picom).

View file

@ -1,152 +0,0 @@
## 🔍 Task Preview <!-- {docsify-ignore} -->
This is a popup widget that will show a preview of the specified client. It is supposed to mimic the small popup that Windows has when hovering over the application icon.
![](https://user-images.githubusercontent.com/33443763/124705653-d7b98b80-deaa-11eb-8091-42bbe62365be.png)
*image by [javacafe](https://github.com/JavaCafe01)*
### Usage
To enable:
```lua
bling.widget.task_preview.enable {
x = 20, -- The x-coord of the popup
y = 20, -- The y-coord of the popup
height = 200, -- The height of the popup
width = 200, -- The width of the popup
placement_fn = function(c) -- Place the widget using awful.placement (this overrides x & y)
awful.placement.bottom(c, {
margins = {
bottom = 30
}
})
end
}
```
To allow for more customization, there is also a `widget_structure` property (as seen in some default awesome widgets) which is optional. An example is as follows -
```lua
bling.widget.task_preview.enable {
x = 20, -- The x-coord of the popup
y = 20, -- The y-coord of the popup
height = 200, -- The height of the popup
width = 200, -- The width of the popup
placement_fn = function(c) -- Place the widget using awful.placement (this overrides x & y)
awful.placement.bottom(c, {
margins = {
bottom = 30
}
})
end,
-- Your widget will automatically conform to the given size due to a constraint container.
widget_structure = {
{
{
{
id = 'icon_role',
widget = awful.widget.clienticon, -- The client icon
},
{
id = 'name_role', -- The client name / title
widget = wibox.widget.textbox,
},
layout = wibox.layout.flex.horizontal
},
widget = wibox.container.margin,
margins = 5
},
{
id = 'image_role', -- The client preview
resize = true,
valign = 'center',
halign = 'center',
widget = wibox.widget.imagebox,
},
layout = wibox.layout.fixed.vertical
}
}
```
Here are the signals available:
```lua
-- bling::task_preview::visibility -- first line is the signal
-- s (screen) -- indented lines are function parameters
-- v (boolean)
-- c (client)
```
By default, the widget is not visible. You must implement when it will update and when it will show.
### Example Implementation
We can trigger the widget to show the specific client when hovering over it in the tasklist. The code shown below is the example icon only tasklist from the [AwesomeWM docs](https://awesomewm.org/doc/api/classes/awful.widget.tasklist.html). Basically, we are going to toggle the widget through the tasklist's `create_callback`. (The bling addons are commented)
```lua
s.mytasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = tasklist_buttons,
layout = {
spacing_widget = {
{
forced_width = 5,
forced_height = 24,
thickness = 1,
color = '#777777',
widget = wibox.widget.separator
},
valign = 'center',
halign = 'center',
widget = wibox.container.place,
},
spacing = 1,
layout = wibox.layout.fixed.horizontal
},
-- Notice that there is *NO* wibox.wibox prefix, it is a template,
-- not a widget instance.
widget_template = {
{
wibox.widget.base.make_widget(),
forced_height = 5,
id = 'background_role',
widget = wibox.container.background,
},
{
{
id = 'clienticon',
widget = awful.widget.clienticon,
},
margins = 5,
widget = wibox.container.margin
},
nil,
create_callback = function(self, c, index, objects) --luacheck: no unused args
self:get_children_by_id('clienticon')[1].client = c
-- BLING: Toggle the popup on hover and disable it off hover
self:connect_signal('mouse::enter', function()
awesome.emit_signal("bling::task_preview::visibility", s,
true, c)
end)
self:connect_signal('mouse::leave', function()
awesome.emit_signal("bling::task_preview::visibility", s,
false, c)
end)
end,
layout = wibox.layout.align.vertical,
},
}
```
### Theme Variables
```lua
theme.task_preview_widget_border_radius = 0 -- Border radius of the widget (With AA)
theme.task_preview_widget_bg = "#000000" -- The bg color of the widget
theme.task_preview_widget_border_color = "#ffffff" -- The border color of the widget
theme.task_preview_widget_border_width = 3 -- The border width of the widget
theme.task_preview_widget_margin = 0 -- The margin of the widget
```
NOTE: I recommend to only use the widget border radius theme variable when not using shadows with a compositor, as anti-aliased rounding with the outer widgets made with AwesomeWM rely on the actual bg being transparent. If you want rounding with shadows on the widget, use a compositor like [jonaburg's fork](https://github.com/jonaburg/picom).

View file

@ -1,67 +0,0 @@
## 🎨 Window Switcher <!-- {docsify-ignore} -->
A popup with client previews that allows you to switch clients similar to the alt-tab menu in MacOS, GNOME, and Windows.
![](https://user-images.githubusercontent.com/70270606/133311802-8aef1012-346f-4f4c-843d-10d9de54ffeb.png)
*image by [No37](https://github.com/Nooo37)*
### Usage
To enable:
```lua
bling.widget.window_switcher.enable {
type = "thumbnail", -- set to anything other than "thumbnail" to disable client previews
-- keybindings (the examples provided are also the default if kept unset)
hide_window_switcher_key = "Escape", -- The key on which to close the popup
minimize_key = "n", -- The key on which to minimize the selected client
unminimize_key = "N", -- The key on which to unminimize all clients
kill_client_key = "q", -- The key on which to close the selected client
cycle_key = "Tab", -- The key on which to cycle through all clients
previous_key = "Left", -- The key on which to select the previous client
next_key = "Right", -- The key on which to select the next client
vim_previous_key = "h", -- Alternative key on which to select the previous client
vim_next_key = "l", -- Alternative key on which to select the next client
cycleClientsByIdx = awful.client.focus.byidx, -- The function to cycle the clients
filterClients = awful.widget.tasklist.filter.currenttags, -- The function to filter the viewed clients
}
```
To run the window swicher you have to emit this signal from within your configuration (usually using a keybind).
```lua
awesome.emit_signal("bling::window_switcher::turn_on")
```
For example:
```lua
awful.key({Mod1}, "Tab", function()
awesome.emit_signal("bling::window_switcher::turn_on")
end, {description = "Window Switcher", group = "bling"})
```
### Theme Variables
```lua
theme.window_switcher_widget_bg = "#000000" -- The bg color of the widget
theme.window_switcher_widget_border_width = 3 -- The border width of the widget
theme.window_switcher_widget_border_radius = 0 -- The border radius of the widget
theme.window_switcher_widget_border_color = "#ffffff" -- The border color of the widget
theme.window_switcher_clients_spacing = 20 -- The space between each client item
theme.window_switcher_client_icon_horizontal_spacing = 5 -- The space between client icon and text
theme.window_switcher_client_width = 150 -- The width of one client widget
theme.window_switcher_client_height = 250 -- The height of one client widget
theme.window_switcher_client_margins = 10 -- The margin between the content and the border of the widget
theme.window_switcher_thumbnail_margins = 10 -- The margin between one client thumbnail and the rest of the widget
theme.thumbnail_scale = false -- If set to true, the thumbnails fit policy will be set to "fit" instead of "auto"
theme.window_switcher_name_margins = 10 -- The margin of one clients title to the rest of the widget
theme.window_switcher_name_valign = "center" -- How to vertically align one clients title
theme.window_switcher_name_forced_width = 200 -- The width of one title
theme.window_switcher_name_font = "sans 11" -- The font of all titles
theme.window_switcher_name_normal_color = "#ffffff" -- The color of one title if the client is unfocused
theme.window_switcher_name_focus_color = "#ff0000" -- The color of one title if the client is focused
theme.window_switcher_icon_valign = "center" -- How to vertically align the one icon
theme.window_switcher_icon_width = 40 -- The width of one icon
```

View file

@ -1,127 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local _client = {}
--- Turn off passed client
-- Remove current tag from window's tags
--
-- @param c A client
function _client.turn_off(c, current_tag)
if current_tag == nil then
current_tag = c.screen.selected_tag
end
local ctags = {}
for k, tag in pairs(c:tags()) do
if tag ~= current_tag then
table.insert(ctags, tag)
end
end
c:tags(ctags)
c.sticky = false
end
--- Turn on passed client (add current tag to window's tags)
--
-- @param c A client
function _client.turn_on(c)
local current_tag = c.screen.selected_tag
ctags = { current_tag }
for k, tag in pairs(c:tags()) do
if tag ~= current_tag then
table.insert(ctags, tag)
end
end
c:tags(ctags)
c:raise()
client.focus = c
end
--- Sync two clients
--
-- @param to_c The client to which to write all properties
-- @param from_c The client from which to read all properties
function _client.sync(to_c, from_c)
if not from_c or not to_c then
return
end
if not from_c.valid or not to_c.valid then
return
end
if from_c.modal then
return
end
to_c.floating = from_c.floating
to_c.maximized = from_c.maximized
to_c.above = from_c.above
to_c.below = from_c.below
to_c:geometry(from_c:geometry())
-- TODO: Should also copy over the position in a tiling layout
end
--- Checks whether the passed client is a childprocess of a given process ID
--
-- @param c A client
-- @param pid The process ID
-- @return True if the passed client is a childprocess of the given PID otherwise false
function _client.is_child_of(c, pid)
-- io.popen is normally discouraged. Should probably be changed
if not c or not c.valid then
return false
end
if tostring(c.pid) == tostring(pid) then
return true
end
local pid_cmd = [[pstree -T -p -a -s ]]
.. tostring(c.pid)
.. [[ | sed '2q;d' | grep -o '[0-9]*$' | tr -d '\n']]
local handle = io.popen(pid_cmd)
local parent_pid = handle:read("*a")
handle:close()
return tostring(parent_pid) == tostring(pid)
or tostring(parent_pid) == tostring(c.pid)
end
--- Finds all clients that satisfy the passed rule
--
-- @param rule The rule to be searched for
-- @retrun A list of clients that match the given rule
function _client.find(rule)
local function matcher(c)
return awful.rules.match(c, rule)
end
local clients = client.get()
local findex = gears.table.hasitem(clients, client.focus) or 1
local start = gears.math.cycle(#clients, findex + 1)
local matches = {}
for c in awful.client.iterate(matcher, start) do
matches[#matches + 1] = c
end
return matches
end
--- Gets the next client by direction from the focused one
--
-- @param direction it the direction as a string ("up", "down", "left" or "right")
-- @retrun the client in the given direction starting at the currently focused one, nil otherwise
function _client.get_by_direction(direction)
local sel = client.focus
if not sel then
return nil
end
local cltbl = sel.screen:get_clients()
local geomtbl = {}
for i, cl in ipairs(cltbl) do
geomtbl[i] = cl:geometry()
end
local target = gears.geometry.rectangle.get_in_direction(
direction,
geomtbl,
sel:geometry()
)
return cltbl[target]
end
return _client

View file

@ -1,158 +0,0 @@
local tonumber = tonumber
local string = string
local math = math
local floor = math.floor
local max = math.max
local min = math.min
local abs = math.abs
local format = string.format
local _color = {}
--- Try to guess if a color is dark or light.
--
-- @string color The color with hexadecimal HTML format `"#RRGGBB"`.
-- @treturn bool `true` if the color is dark, `false` if it is light.
function _color.is_dark(color)
-- Try to determine if the color is dark or light
local numeric_value = 0
for s in color:gmatch("[a-fA-F0-9][a-fA-F0-9]") do
numeric_value = numeric_value + tonumber("0x" .. s)
end
return (numeric_value < 383)
end
function _color.is_opaque(color)
if type(color) == "string" then
color = _color.hex_to_rgba(color)
end
return color.a < 0.01
end
--- Lighten a color.
--
-- @string color The color to lighten with hexadecimal HTML format `"#RRGGBB"`.
-- @int[opt=26] amount How much light from 0 to 255. Default is around 10%.
-- @treturn string The lighter color
function _color.lighten(color, amount)
amount = amount or 26
local c = {
r = tonumber("0x" .. color:sub(2, 3)),
g = tonumber("0x" .. color:sub(4, 5)),
b = tonumber("0x" .. color:sub(6, 7)),
}
c.r = c.r + amount
c.r = c.r < 0 and 0 or c.r
c.r = c.r > 255 and 255 or c.r
c.g = c.g + amount
c.g = c.g < 0 and 0 or c.g
c.g = c.g > 255 and 255 or c.g
c.b = c.b + amount
c.b = c.b < 0 and 0 or c.b
c.b = c.b > 255 and 255 or c.b
return string.format("#%02x%02x%02x", c.r, c.g, c.b)
end
--- Darken a color.
--
-- @string color The color to darken with hexadecimal HTML format `"#RRGGBB"`.
-- @int[opt=26] amount How much dark from 0 to 255. Default is around 10%.
-- @treturn string The darker color
function _color.darken(color, amount)
amount = amount or 26
return _color.lighten(color, -amount)
end
-- Returns a value that is clipped to interval edges if it falls outside the interval
function _color.clip(num, min_num, max_num)
return max(min(num, max_num), min_num)
end
-- Converts the given hex color to rgba
function _color.hex_to_rgba(color)
color = color:gsub("#", "")
return { r = tonumber("0x" .. color:sub(1, 2)),
g = tonumber("0x" .. color:sub(3, 4)),
b = tonumber("0x" .. color:sub(5, 6)),
a = #color == 8 and tonumber("0x" .. color:sub(7, 8)) or 255 }
end
-- Converts the given rgba color to hex
function _color.rgba_to_hex(color)
local r = _color.clip(color.r or color[1], 0, 255)
local g = _color.clip(color.g or color[2], 0, 255)
local b = _color.clip(color.b or color[3], 0, 255)
local a = _color.clip(color.a or color[4] or 255, 0, 255)
return "#" .. format("%02x%02x%02x%02x",
floor(r),
floor(g),
floor(b),
floor(a))
end
-- Converts the given hex color to hsv
function _color.hex_to_hsv(color)
local color = _color.hex2rgb(color)
local C_max = max(color.r, color.g, color.b)
local C_min = min(color.r, color.g, color.b)
local delta = C_max - C_min
local H, S, V
if delta == 0 then
H = 0
elseif C_max == color.r then
H = 60 * (((color.g - color.b) / delta) % 6)
elseif C_max == color.g then
H = 60 * (((color.b - color.r) / delta) + 2)
elseif C_max == color.b then
H = 60 * (((color.r - color.g) / delta) + 4)
end
if C_max == 0 then
S = 0
else
S = delta / C_max
end
V = C_max
return { h = H,
s = S * 100,
v = V * 100 }
end
-- Converts the given hsv color to hex
function _color.hsv_to_hex(H, S, V)
S = S / 100
V = V / 100
if H > 360 then H = 360 end
if H < 0 then H = 0 end
local C = V * S
local X = C * (1 - abs(((H / 60) % 2) - 1))
local m = V - C
local r_, g_, b_ = 0, 0, 0
if H >= 0 and H < 60 then
r_, g_, b_ = C, X, 0
elseif H >= 60 and H < 120 then
r_, g_, b_ = X, C, 0
elseif H >= 120 and H < 180 then
r_, g_, b_ = 0, C, X
elseif H >= 180 and H < 240 then
r_, g_, b_ = 0, X, C
elseif H >= 240 and H < 300 then
r_, g_, b_ = X, 0, C
elseif H >= 300 and H < 360 then
r_, g_, b_ = C, 0, X
end
local r, g, b = (r_ + m) * 255, (g_ + m) * 255, (b_ + m) * 255
return ("#%02x%02x%02x"):format(floor(r), floor(g), floor(b))
end
function _color.multiply(color, amount)
return { _color.clip(color.r * amount, 0, 255),
_color.clip(color.g * amount, 0, 255),
_color.clip(color.b * amount, 0, 255),
255 }
end
return _color

View file

@ -1,62 +0,0 @@
local Gio = require("lgi").Gio
local awful = require("awful")
local string = string
local _filesystem = {}
--- Get a list of files from a given directory.
-- @string path The directory to search.
-- @tparam[opt] table exts Specific extensions to limit the search to. eg:`{ "jpg", "png" }`
-- If ommited, all files are considered.
-- @bool[opt=false] recursive List files from subdirectories
-- @staticfct bling.helpers.filesystem.get_random_file_from_dir
function _filesystem.list_directory_files(path, exts, recursive)
recursive = recursive or false
local files, valid_exts = {}, {}
-- Transforms { "jpg", ... } into { [jpg] = #, ... }
if exts then
for i, j in ipairs(exts) do
valid_exts[j:lower()] = i
end
end
-- Build a table of files from the path with the required extensions
local file_list = Gio.File.new_for_path(path):enumerate_children(
"standard::*",
0
)
if file_list then
for file in function()
return file_list:next_file()
end do
local file_type = file:get_file_type()
if file_type == "REGULAR" then
local file_name = file:get_display_name()
if
not exts
or valid_exts[file_name:lower():match(".+%.(.*)$") or ""]
then
table.insert(files, file_name)
end
elseif recursive and file_type == "DIRECTORY" then
local file_name = file:get_display_name()
files = gears.table.join(
files,
list_directory_files(file_name, exts, recursive)
)
end
end
end
return files
end
function _filesystem.save_image_async_curl(url, filepath, callback)
awful.spawn.with_line_callback(string.format("curl -L -s %s -o %s", url, filepath),
{
exit=callback
})
end
return _filesystem

View file

@ -1,142 +0,0 @@
local lgi = require("lgi")
local Gio = lgi.Gio
local Gtk = lgi.require("Gtk", "3.0")
local gobject = require("gears.object")
local gtable = require("gears.table")
local setmetatable = setmetatable
local ipairs = ipairs
local icon_theme = { mt = {} }
local name_lookup =
{
["jetbrains-studio"] = "android-studio"
}
local function get_icon_by_pid_command(self, client, apps)
local pid = client.pid
if pid ~= nil then
local handle = io.popen(string.format("ps -p %d -o comm=", pid))
local pid_command = handle:read("*a"):gsub("^%s*(.-)%s*$", "%1")
handle:close()
for _, app in ipairs(apps) do
local executable = app:get_executable()
if executable and executable:find(pid_command, 1, true) then
return self:get_gicon_path(app:get_icon())
end
end
end
end
local function get_icon_by_icon_name(self, client, apps)
local icon_name = client.icon_name and client.icon_name:lower() or nil
if icon_name ~= nil then
for _, app in ipairs(apps) do
local name = app:get_name():lower()
if name and name:find(icon_name, 1, true) then
return self:get_gicon_path(app:get_icon())
end
end
end
end
local function get_icon_by_class(self, client, apps)
if client.class ~= nil then
local class = name_lookup[client.class] or client.class:lower()
-- Try to remove dashes
local class_1 = class:gsub("[%-]", "")
-- Try to replace dashes with dot
local class_2 = class:gsub("[%-]", ".")
-- Try to match only the first word
local class_3 = class:match("(.-)-") or class
class_3 = class_3:match("(.-)%.") or class_3
class_3 = class_3:match("(.-)%s+") or class_3
local possible_icon_names = { class, class_3, class_2, class_1 }
for _, app in ipairs(apps) do
local id = app:get_id():lower()
for _, possible_icon_name in ipairs(possible_icon_names) do
if id and id:find(possible_icon_name, 1, true) then
return self:get_gicon_path(app:get_icon())
end
end
end
end
end
function icon_theme:get_client_icon_path(client)
local apps = Gio.AppInfo.get_all()
return get_icon_by_pid_command(self, client, apps) or
get_icon_by_icon_name(self, client, apps) or
get_icon_by_class(self, client, apps) or
client.icon or
self:choose_icon({"window", "window-manager", "xfwm4-default", "window_list" })
end
function icon_theme:choose_icon(icons_names)
local icon_info = self.gtk_theme:choose_icon(icons_names, self.icon_size, 0);
if icon_info then
local icon_path = icon_info:get_filename()
if icon_path then
return icon_path
end
end
return ""
end
function icon_theme:get_gicon_path(gicon)
if gicon == nil then
return ""
end
local icon_info = self.gtk_theme:lookup_by_gicon(gicon, self.icon_size, 0);
if icon_info then
local icon_path = icon_info:get_filename()
if icon_path then
return icon_path
end
end
return ""
end
function icon_theme:get_icon_path(icon_name)
local icon_info = self.gtk_theme:lookup_icon(icon_name, self.icon_size, 0)
if icon_info then
local icon_path = icon_info:get_filename()
if icon_path then
return icon_path
end
end
return ""
end
local function new(theme_name, icon_size)
local ret = gobject{}
gtable.crush(ret, icon_theme, true)
ret.name = theme_name or nil
ret.icon_size = icon_size or 48
if theme_name then
ret.gtk_theme = Gtk.IconTheme.new()
Gtk.IconTheme.set_custom_theme(ret.gtk_theme, theme_name);
else
ret.gtk_theme = Gtk.IconTheme.get_default()
end
return ret
end
function icon_theme.mt:__call(...)
return new(...)
end
return setmetatable(icon_theme, icon_theme.mt)

View file

@ -1,7 +0,0 @@
return {
client = require(... .. ".client"),
color = require(... .. ".color"),
filesystem = require(... .. ".filesystem"),
shape = require(... .. ".shape"),
time = require(... .. ".time"),
}

View file

@ -1,30 +0,0 @@
local gears = require("gears")
local shape = {}
-- Create rounded rectangle shape (in one line)
function shape.rrect(radius)
return function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, radius)
end
end
-- Create partially rounded rect
function shape.prrect(radius, tl, tr, br, bl)
return function(cr, width, height)
gears.shape.partially_rounded_rect(
cr,
width,
height,
tl,
tr,
br,
bl,
radius
)
end
end
return shape

View file

@ -1,24 +0,0 @@
local time = {}
--- Parse a time string to seconds (from midnight)
--
-- @string time The time (`HH:MM:SS`)
-- @treturn int The number of seconds since 00:00:00
function time.hhmmss_to_seconds(time)
hour_sec = tonumber(string.sub(time, 1, 2)) * 3600
min_sec = tonumber(string.sub(time, 4, 5)) * 60
get_sec = tonumber(string.sub(time, 7, 8))
return (hour_sec + min_sec + get_sec)
end
--- Get time difference in seconds.
--
-- @tparam string base The time to compare from (`HH:MM:SS`).
-- @tparam string base The time to compare to (`HH:MM:SS`).
-- @treturn int Number of seconds between the two times.
function time.time_diff(base, compare)
local diff = time.hhmmss_to_seconds(base) - time.hhmmss_to_seconds(compare)
return diff
end
return time

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View file

@ -1,11 +0,0 @@
--[[
Bling
Layouts, widgets and utilities for Awesome WM
--]]
return {
layout = require(... .. ".layout"),
module = require(... .. ".module"),
helpers = require(... .. ".helpers"),
signal = require(... .. ".signal"),
widget = require(... .. ".widget"),
}

View file

@ -1,80 +0,0 @@
local awful = require("awful")
local math = math
local mylayout = {}
mylayout.name = "centered"
function mylayout.arrange(p)
local area = p.workarea
local t = p.tag or screen[p.screen].selected_tag
local nmaster = math.min(t.master_count, #p.clients)
local nslaves = #p.clients - nmaster
local master_area_width = area.width * t.master_width_factor
if t.master_count == 0 then master_area_width = 0 end
local slave_width = 0.5 * (area.width - master_area_width)
local master_area_x = area.x + slave_width
-- Special case: few slaves -> make masters take more space - unless requested otherwise!
if nslaves < 2 and t.master_fill_policy ~= "master_width_factor" then
master_area_x = area.x
if nslaves == 1 then
slave_width = area.width - master_area_width
else
master_area_width = area.width
end
end
-- iterate through masters
for idx = 1, nmaster do
local c = p.clients[idx]
local g
g = {
x = master_area_x,
y = area.y + (nmaster - idx) * (area.height / nmaster),
width = master_area_width,
height = area.height / nmaster,
}
p.geometries[c] = g
end
-- iterate through slaves
local number_of_left_sided_slaves = math.floor(nslaves / 2)
local number_of_right_sided_slaves = nslaves - number_of_left_sided_slaves
local left_iterator = 0
local right_iterator = 0
for idx = 1, nslaves do
local c = p.clients[idx + nmaster]
local g
if idx % 2 == 0 then
g = {
x = area.x,
y = area.y
+ left_iterator
* (area.height / number_of_left_sided_slaves),
width = slave_width,
height = area.height / number_of_left_sided_slaves,
}
left_iterator = left_iterator + 1
else
g = {
x = master_area_x + master_area_width,
y = area.y
+ right_iterator
* (area.height / number_of_right_sided_slaves),
width = slave_width,
height = area.height / number_of_right_sided_slaves,
}
right_iterator = right_iterator + 1
end
p.geometries[c] = g
end
end
return mylayout

View file

@ -1,37 +0,0 @@
local mylayout = {}
mylayout.name = "deck"
function mylayout.arrange(p)
local area = p.workarea
local t = p.tag or screen[p.screen].selected_tag
local client_count = #p.clients
if client_count == 1 then
local c = p.clients[1]
local g = {
x = area.x,
y = area.y,
width = area.width,
height = area.height,
}
p.geometries[c] = g
return
end
local xoffset = area.width * 0.1 / (client_count - 1)
local yoffset = area.height * 0.1 / (client_count - 1)
for idx = 1, client_count do
local c = p.clients[idx]
local g = {
x = area.x + (idx - 1) * xoffset,
y = area.y + (idx - 1) * yoffset,
width = area.width - (xoffset * (client_count - 1)),
height = area.height - (yoffset * (client_count - 1)),
}
p.geometries[c] = g
end
end
return mylayout

View file

@ -1,77 +0,0 @@
local math = math
local screen = screen
local mylayout = {}
mylayout.name = "equalarea"
local function divide(p, g, low, high, cls, mwfact, mcount)
if low == high then
p.geometries[cls[low]] = g
else
local masters = math.max(0, math.min(mcount, high) - low + 1)
local numblock = high - low + 1
local slaves = numblock - masters
local smalldiv
if numblock > 5 and (numblock % 5) == 0 then
smalldiv = math.floor(numblock / 5)
else
if (numblock % 3) == 0 then
smalldiv = math.floor(numblock / 3)
else
smalldiv = math.floor(numblock / 2)
end
end
local bigdiv = numblock - smalldiv
local smallmasters = math.min(masters, smalldiv)
local bigmasters = masters - smallmasters
local smallg = {}
local bigg = {}
smallg.x = g.x
smallg.y = g.y
if g.width > (g.height * 1.3) then
smallg.height = g.height
bigg.height = g.height
bigg.width = math.floor(
g.width
* (bigmasters * (mwfact - 1) + bigdiv)
/ (slaves + mwfact * masters)
)
smallg.width = g.width - bigg.width
bigg.y = g.y
bigg.x = g.x + smallg.width
else
smallg.width = g.width
bigg.width = g.width
bigg.height = math.floor(
g.height
* (bigmasters * (mwfact - 1) + bigdiv)
/ (slaves + mwfact * masters)
)
smallg.height = g.height - bigg.height
bigg.x = g.x
bigg.y = g.y + smallg.height
end
divide(p, smallg, low, high - bigdiv, cls, mwfact, mcount)
divide(p, bigg, low + smalldiv, high, cls, mwfact, mcount)
end
return
end
function mylayout.arrange(p)
local t = p.tag or screen[p.screen].selected_tag
local wa = p.workarea
local cls = p.clients
if #cls == 0 then
return
end
local mwfact = t.master_width_factor * 2
local mcount = t.master_count
local g = {}
g.height = wa.height
g.width = wa.width
g.x = wa.x
g.y = wa.y
divide(p, g, 1, #cls, cls, mwfact, mcount)
end
return mylayout

View file

@ -1,56 +0,0 @@
local math = math
local mylayout = {}
mylayout.name = "horizontal"
function mylayout.arrange(p)
local area = p.workarea
local t = p.tag or screen[p.screen].selected_tag
local mwfact = t.master_width_factor
local nmaster = math.min(t.master_count, #p.clients)
local nslaves = #p.clients - nmaster
local master_area_height = area.height * mwfact
local slave_area_height = area.height - master_area_height
-- Special case: no slaves
if nslaves == 0 then
master_area_height = area.height
slave_area_height = 0
end
-- Special case: no masters
if nmaster == 0 then
master_area_height = 0
slave_area_height = area.height
end
-- itearte through masters
for idx = 1, nmaster do
local c = p.clients[idx]
local g = {
x = area.x + (idx - 1) * (area.width / nmaster),
y = area.y,
width = area.width / nmaster,
height = master_area_height,
}
p.geometries[c] = g
end
-- iterate through slaves
for idx = 1, nslaves do
local c = p.clients[idx + nmaster]
local g = {
x = area.x,
y = area.y
+ master_area_height
+ (idx - 1) * (slave_area_height / nslaves),
width = area.width,
height = slave_area_height / nslaves,
}
p.geometries[c] = g
end
end
return mylayout

View file

@ -1,46 +0,0 @@
local beautiful = require("beautiful")
local gears = require("gears")
local M = {}
local relative_lua_path = tostring(...)
local function get_layout_icon_path(name)
local relative_icon_path = relative_lua_path
:match("^.*bling"):gsub("%.", "/")
.. "/icons/layouts/" .. name .. ".png"
for p in package.path:gmatch('([^;]+)') do
p = p:gsub("?.*", "")
local absolute_icon_path = p .. relative_icon_path
if gears.filesystem.file_readable(absolute_icon_path) then
return absolute_icon_path
end
end
end
local function get_icon(icon_raw)
if icon_raw ~= nil then
return gears.color.recolor_image(icon_raw, beautiful.fg_normal)
else
return nil
end
end
local layouts = {
"mstab",
"vertical",
"horizontal",
"centered",
"equalarea",
"deck"
}
for _, layout_name in ipairs(layouts) do
local icon_raw = get_layout_icon_path(layout_name)
if beautiful["layout_" .. layout_name] == nil then
beautiful["layout_" .. layout_name] = get_icon(icon_raw)
end
M[layout_name] = require(... .. "." .. layout_name)
end
return M

View file

@ -1,236 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local mylayout = {}
mylayout.name = "mstab"
local tabbar_disable = beautiful.mstab_bar_disable or false
local tabbar_ontop = beautiful.mstab_bar_ontop or false
local tabbar_padding = beautiful.mstab_bar_padding or "default"
local border_radius = beautiful.mstab_border_radius
or beautiful.border_radius
or 0
local tabbar_position = beautiful.mstab_tabbar_position
or beautiful.tabbar_position
or "top"
local bar_style = beautiful.mstab_tabbar_style
or beautiful.tabbar_style
or "default"
local bar = require(
tostring(...):match(".*bling") .. ".widget.tabbar." .. bar_style
)
local tabbar_size = bar.size
or beautiful.mstab_bar_height
or beautiful.tabbar_size
or 40
local dont_resize_slaves = beautiful.mstab_dont_resize_slaves or false
-- The top_idx is the idx of the slave clients (excluding all master clients)
-- that should be on top of all other slave clients ("the focused slave")
-- by creating a variable outside of the arrange function, this layout can "remember" that client
-- by creating it as a new property of every tag, this layout can be active on different tags and
-- still have different "focused slave clients"
for idx, tag in ipairs(root.tags()) do
tag.top_idx = 1
end
-- Haven't found a signal that is emitted when a new tag is added. That should work though
-- since you can't use a layout on a tag that you haven't selected previously
tag.connect_signal("property::selected", function(t)
if not t.top_idx then
t.top_idx = 1
end
end)
function update_tabbar(
clients,
t,
top_idx,
area,
master_area_width,
slave_area_width
)
local s = t.screen
-- create the list of clients for the tabbar
local clientlist = bar.layout()
for idx, c in ipairs(clients) do
-- focus with right click, kill with mid click, minimize with left click
local buttons = gears.table.join(
awful.button({}, 1, function()
c:raise()
client.focus = c
end),
awful.button({}, 2, function()
c:kill()
end),
awful.button({}, 3, function()
c.minimized = true
end)
)
local client_box = bar.create(c, (idx == top_idx), buttons)
clientlist:add(client_box)
end
-- if no tabbar exists, create one
if not s.tabbar then
s.tabbar = wibox({
ontop = tabbar_ontop,
shape = function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, border_radius)
end,
bg = bar.bg_normal,
visible = true,
})
-- Change visibility of the tab bar when layout, selected tag or number of clients (visible, master, slave) changes
local function adjust_visibility()
local name = awful.layout.getname( awful.layout.get( s ) )
s.tabbar.visible = (name == mylayout.name)
end
tag.connect_signal("property::selected", adjust_visibility)
tag.connect_signal("property::layout", adjust_visibility)
tag.connect_signal("tagged", adjust_visibility)
tag.connect_signal("untagged", adjust_visibility)
tag.connect_signal("property::master_count", adjust_visibility)
client.connect_signal("property::minimized", adjust_visibility)
end
-- update the tabbar size and position (to support gap size change on the fly)
if tabbar_position == "top" then
s.tabbar.x = area.x + master_area_width + t.gap
s.tabbar.y = area.y + t.gap
s.tabbar.width = slave_area_width - 2 * t.gap
s.tabbar.height = tabbar_size
elseif tabbar_position == "bottom" then
s.tabbar.x = area.x + master_area_width + t.gap
s.tabbar.y = area.y + area.height - tabbar_size - t.gap
s.tabbar.width = slave_area_width - 2 * t.gap
s.tabbar.height = tabbar_size
elseif tabbar_position == "left" then
s.tabbar.x = area.x + master_area_width + t.gap
s.tabbar.y = area.y + t.gap
s.tabbar.width = tabbar_size
s.tabbar.height = area.height - 2 * t.gap
elseif tabbar_position == "right" then
s.tabbar.x = area.x
+ master_area_width
+ slave_area_width
- tabbar_size
- t.gap
s.tabbar.y = area.y + t.gap
s.tabbar.width = tabbar_size
s.tabbar.height = area.height - 2 * t.gap
end
-- update clientlist
s.tabbar:setup({ layout = wibox.layout.flex.horizontal, clientlist })
end
function mylayout.arrange(p)
local area = p.workarea
local t = p.tag or screen[p.screen].selected_tag
local s = t.screen
local mwfact = t.master_width_factor
local nmaster = math.min(t.master_count, #p.clients)
local nslaves = #p.clients - nmaster
local master_area_width = area.width * mwfact
local slave_area_width = area.width - master_area_width
-- "default" means that it uses standard useless gap size
if tabbar_padding == "default" then
tabbar_padding = 2 * t.gap
end
-- Special case: No masters -> full screen slave width
if nmaster == 0 then
master_area_width = 1
slave_area_width = area.width
end
-- Special case: One or zero slaves -> no tabbar (essentially tile right)
if nslaves <= 1 then
-- since update_tabbar isnt called that way we have to hide it manually
if s.tabbar then
s.tabbar.visible = false
end
-- otherwise just do tile right
awful.layout.suit.tile.right.arrange(p)
return
end
-- Iterate through masters
for idx = 1, nmaster do
local c = p.clients[idx]
local g = {
x = area.x,
y = area.y + (idx - 1) * (area.height / nmaster),
width = master_area_width,
height = area.height / nmaster,
}
p.geometries[c] = g
end
local tabbar_size_change = 0
local tabbar_width_change = 0
local tabbar_y_change = 0
local tabbar_x_change = 0
if not tabbar_disable then
if tabbar_position == "top" then
tabbar_size_change = tabbar_size + tabbar_padding
tabbar_y_change = tabbar_size + tabbar_padding
elseif tabbar_position == "bottom" then
tabbar_size_change = tabbar_size + tabbar_padding
elseif tabbar_position == "left" then
tabbar_width_change = tabbar_size + tabbar_padding
tabbar_x_change = tabbar_size + tabbar_padding
elseif tabbar_position == "right" then
tabbar_width_change = tabbar_size + tabbar_padding
end
end
-- Iterate through slaves
-- (also creates a list of all slave clients for update_tabbar)
local slave_clients = {}
for idx = 1, nslaves do
local c = p.clients[idx + nmaster]
slave_clients[#slave_clients + 1] = c
if c == client.focus then
t.top_idx = #slave_clients
end
local g = {
x = area.x + master_area_width + tabbar_x_change,
y = area.y + tabbar_y_change,
width = slave_area_width - tabbar_width_change,
height = area.height - tabbar_size_change,
}
if not dont_resize_slaves and idx ~= t.top_idx then
g = {
x = area.x + master_area_width + slave_area_width / 4,
y = area.y + tabbar_size + area.height / 4,
width = slave_area_width / 2,
height = area.height / 4 - tabbar_size,
}
end
p.geometries[c] = g
end
if not tabbar_disable then
update_tabbar(
slave_clients,
t,
t.top_idx,
area,
master_area_width,
slave_area_width
)
end
end
return mylayout

View file

@ -1,56 +0,0 @@
local math = math
local mylayout = {}
mylayout.name = "vertical"
function mylayout.arrange(p)
local area = p.workarea
local t = p.tag or screen[p.screen].selected_tag
local mwfact = t.master_width_factor
local nmaster = math.min(t.master_count, #p.clients)
local nslaves = #p.clients - nmaster
local master_area_width = area.width * mwfact
local slave_area_width = area.width - master_area_width
-- Special case: no slaves
if nslaves == 0 then
master_area_width = area.width
slave_area_width = 0
end
-- Special case: no masters
if nmaster == 0 then
master_area_width = 0
slave_area_width = area.width
end
-- iterate through masters
for idx = 1, nmaster do
local c = p.clients[idx]
local g = {
x = area.x,
y = area.y + (idx - 1) * (area.height / nmaster),
width = master_area_width,
height = area.height / nmaster,
}
p.geometries[c] = g
end
-- itearte through slaves
for idx = 1, nslaves do
local c = p.clients[idx + nmaster]
local g = {
x = area.x
+ master_area_width
+ (idx - 1) * (slave_area_width / nslaves),
y = area.y,
width = slave_area_width / nslaves,
height = area.height,
}
p.geometries[c] = g
end
end
return mylayout

View file

@ -1,39 +0,0 @@
local gears = require("gears")
local beautiful = require("beautiful")
local op = beautiful.flash_focus_start_opacity or 0.6
local stp = beautiful.flash_focus_step or 0.01
local flashfocus = function(c)
if c and #c.screen.clients > 1 then
c.opacity = op
local q = op
local g = gears.timer({
timeout = stp,
call_now = false,
autostart = true,
})
g:connect_signal("timeout", function()
if not c.valid then
return
end
if q >= 1 then
c.opacity = 1
g:stop()
else
c.opacity = q
q = q + stp
end
end)
end
end
local enable = function()
client.connect_signal("focus", flashfocus)
end
local disable = function()
client.disconnect_signal("focus", flashfocus)
end
return { enable = enable, disable = disable, flashfocus = flashfocus }

View file

@ -1,8 +0,0 @@
return {
window_swallowing = require(... .. ".window_swallowing"),
tiled_wallpaper = require(... .. ".tiled_wallpaper"),
wallpaper = require(... .. ".wallpaper"),
flash_focus = require(... .. ".flash_focus"),
tabbed = require(... .. ".tabbed"),
scratchpad = require(... .. ".scratchpad"),
}

View file

@ -1,374 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local naughty = require("naughty")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local capi = { awesome = awesome, client = client }
local ruled = capi.awesome.version ~= "v4.3" and require("ruled") or nil
local pairs = pairs
local Scratchpad = { mt = {} }
--- Called when the turn off animation has ended
local function on_animate_turn_off_end(self, tag)
-- When toggling off a scratchpad that's present on multiple tags
-- depsite still being unminizmied on the other tags it will become invisible
-- as it's position could be outside the screen from the animation
self.client:geometry({
x = self.geometry.x + self.client.screen.geometry.x,
y = self.geometry.y + self.client.screen.geometry.y,
width = self.geometry.width,
height = self.geometry.height,
})
helpers.client.turn_off(self.client, tag)
self.turning_off = false
self:emit_signal("turn_off", self.client)
end
--- The turn off animation
local function animate_turn_off(self, anim, axis)
self.screen_on_toggled_scratchpad = self.client.screen
self.tag_on_toggled_scratchpad = self.screen_on_toggled_scratchpad.selected_tag
if self.client.floating == false then
-- Save the client geometry before floating it
local non_floating_x = self.client.x
local non_floating_y = self.client.y
local non_floating_width = self.client.width
local non_floating_height = self.client.height
-- Can't animate non floating clients
self.client.floating = true
-- Set the client geometry back to what it was before floating it
self.client:geometry({
x = non_floating_x,
y = non_floating_y,
width = non_floating_width,
height = non_floating_height,
})
end
if axis == "x" then
anim.pos = self.client.x
else
anim.pos = self.client.y
end
anim:set(anim:initial())
end
-- Handles changing tag mid animation
local function abort_if_tag_was_switched(self)
-- Check for the following scenerio:
-- Toggle on scratchpad at tag 1
-- Toggle on scratchpad at tag 2
-- Toggle off scratchpad at tag 1
-- Switch to tag 2
-- Outcome: The client will remain on tag 1 and will instead be removed from tag 2
if (self.turning_off) and (self.screen_on_toggled_scratchpad and
self.screen_on_toggled_scratchpad.selected_tag) ~= self.tag_on_toggled_scratchpad
then
if self.rubato.x then
self.rubato.x:abort()
end
if self.rubato.y then
self.rubato.y:abort()
end
on_animate_turn_off_end(self, self.tag_on_toggled_scratchpad)
self.screen_on_toggled_scratchpad.selected_tag = nil
self.tag_on_toggled_scratchpad = nil
end
end
--- The turn on animation
local function animate_turn_on(self, anim, axis)
-- Check for the following scenerio:
-- Toggle on scratchpad at tag 1
-- Toggle on scratchpad at tag 2
-- The animation will instantly end
-- as the timer pos is already at the on position
-- from toggling on the scratchpad at tag 1
if axis == "x" and anim.pos == self.geometry.x then
anim.pos = anim:initial()
else
if anim.pos == self.geometry.y then
anim.pos = anim:initial()
end
end
if axis == "x" then
anim:set(self.geometry.x)
else
anim:set(self.geometry.y)
end
end
--- Creates a new scratchpad object based on the argument
--
-- @param args A table of possible arguments
-- @return The new scratchpad object
function Scratchpad:new(args)
args = args or {}
if args.awestore then
naughty.notify({
title = "Bling Error",
text = "Awestore is no longer supported! Please take a look at the scratchpad documentation and use rubato for animations instead.",
})
end
args.rubato = args.rubato or {}
local ret = gears.object{}
gears.table.crush(ret, Scratchpad)
gears.table.crush(ret, args)
if ret.rubato.x then
ret.rubato.x:subscribe(function(pos)
if ret.client and ret.client.valid then
ret.client.x = pos
end
abort_if_tag_was_switched(ret)
end)
ret.rubato.x.ended:subscribe(function()
if ((ret.rubato.y and ret.rubato.y.state == false) or (ret.rubato.y == nil)) and ret.turning_off == true then
on_animate_turn_off_end(ret)
end
end)
end
if ret.rubato.y then
ret.rubato.y:subscribe(function(pos)
if ret.client and ret.client.valid then
ret.client.y = pos
end
abort_if_tag_was_switched(ret)
end)
ret.rubato.y.ended:subscribe(function()
if ((ret.rubato.x and ret.rubato.x.state == false) or (ret.rubato.x == nil)) and ret.turning_off == true then
on_animate_turn_off_end(ret)
end
end)
end
return ret
end
--- Find all clients that satisfy the the rule
--
-- @return A list of all clients that satisfy the rule
function Scratchpad:find()
return helpers.client.find(self.rule)
end
--- Applies the objects scratchpad properties to a given client
--
-- @param c A client to which to apply the properties
function Scratchpad:apply(c)
if not c or not c.valid then
return
end
c.floating = self.floating
c.sticky = self.sticky
c.fullscreen = false
c.maximized = false
c:geometry({
x = self.geometry.x + awful.screen.focused().geometry.x,
y = self.geometry.y + awful.screen.focused().geometry.y,
width = self.geometry.width,
height = self.geometry.height,
})
if self.autoclose then
c:connect_signal("unfocus", function(c1)
c1.sticky = false -- client won't turn off if sticky
helpers.client.turn_off(c1)
end)
end
end
--- Turns the scratchpad on
function Scratchpad:turn_on()
self.client = self:find()[1]
local anim_x = self.rubato.x
local anim_y = self.rubato.y
local in_anim = false
if (anim_x and anim_x.state == true) or (anim_y and anim_y.state == true) then
in_anim = true
end
if self.client and not in_anim and self.client.first_tag and self.client.first_tag.selected then
self.client:raise()
capi.client.focus = self.client
return
end
if self.client and not in_anim then
-- if a client was found, turn it on
if self.reapply then
self:apply(self.client)
end
-- c.sticky was set to false in turn_off so it has to be reapplied anyway
self.client.sticky = self.sticky
if anim_x then
animate_turn_on(self, anim_x, "x")
end
if anim_y then
animate_turn_on(self, anim_y, "y")
end
helpers.client.turn_on(self.client)
self:emit_signal("turn_on", self.client)
return
end
if not self.client then
-- if no client was found, spawn one, find the corresponding window,
-- apply the properties only once (until the next closing)
local pid = awful.spawn.with_shell(self.command)
if capi.awesome.version ~= "v4.3" then
ruled.client.append_rule({
id = "scratchpad",
rule = self.rule,
properties = {
-- If a scratchpad is opened it should spawn at the current tag
-- the same way it will behave if the client was already open
tag = awful.screen.focused().selected_tag,
switch_to_tags = false,
-- Hide the client until the gemoetry rules are applied
hidden = true,
minimized = true,
},
callback = function(c)
-- For a reason I can't quite get the gemotery rules will fail to apply unless we use this timer
gears.timer({
timeout = 0.15,
autostart = true,
single_shot = true,
callback = function()
self.client = c
self:apply(c)
c.hidden = false
c.minimized = false
-- Some clients fail to gain focus
c:activate({})
if anim_x then
animate_turn_on(self, anim_x, "x")
end
if anim_y then
animate_turn_on(self, anim_y, "y")
end
self:emit_signal("inital_apply", c)
-- Discord spawns 2 windows, so keep the rule until the 2nd window shows
if c.name ~= "Discord Updater" then
ruled.client.remove_rule("scratchpad")
end
-- In a case Discord is killed before the second window spawns
c:connect_signal("request::unmanage", function()
ruled.client.remove_rule("scratchpad")
end)
end,
})
end,
})
else
local function inital_apply(c1)
if helpers.client.is_child_of(c1, pid) then
self.client = c1
self:apply(c1)
if anim_x then
animate_turn_on(self, anim_x, "x")
end
if anim_y then
animate_turn_on(self, anim_y, "y")
end
self:emit_signal("inital_apply", c1)
client.disconnect_signal("manage", inital_apply)
end
end
client.connect_signal("manage", inital_apply)
end
end
end
--- Turns the scratchpad off
function Scratchpad:turn_off()
self.client = self:find()[1]
-- Get the tweens
local anim_x = self.rubato.x
local anim_y = self.rubato.y
local in_anim = false
if (anim_x and anim_x.state == true) or (anim_y and anim_y.state == true) then
in_anim = true
end
if self.client and not in_anim then
if anim_x then
self.turning_off = true
animate_turn_off(self, anim_x, "x")
end
if anim_y then
self.turning_off = true
animate_turn_off(self, anim_y, "y")
end
if not anim_x and not anim_y then
helpers.client.turn_off(self.client)
self:emit_signal("turn_off", self.client)
end
end
end
--- Turns the scratchpad off if it is focused otherwise it raises the scratchpad
function Scratchpad:toggle()
local is_turn_off = false
local c = self:find()[1]
if self.dont_focus_before_close then
if c then
if c.sticky and #c:tags() > 0 then
is_turn_off = true
else
local current_tag = c.screen.selected_tag
for k, tag in pairs(c:tags()) do
if tag == current_tag then
is_turn_off = true
break
else
is_turn_off = false
end
end
end
end
else
is_turn_off = capi.client.focus
and awful.rules.match(capi.client.focus, self.rule)
end
if is_turn_off then
self:turn_off()
else
self:turn_on()
end
end
--- Make the module callable without putting a `:new` at the end of it
--
-- @param args A table of possible arguments
-- @return The new scratchpad object
function Scratchpad.mt:__call(...)
return Scratchpad:new(...)
end
return setmetatable(Scratchpad, Scratchpad.mt)

View file

@ -1,276 +0,0 @@
--[[
This module currently works by adding a new property to each client that is tabbed.
That new property is called bling_tabbed.
So each client in a tabbed state has the property "bling_tabbed" which is a table.
Each client that is not tabbed doesn't have that property.
In the function themselves, the same object is refered to as "tabobj" which is why
you will often see something like: "local tabobj = some_client.bling_tabbed" at the beginning
of a function.
--]]
local awful = require("awful")
local wibox = require("wibox")
local gears = require("gears")
local beautiful = require("beautiful")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local bar_style = beautiful.tabbar_style or "default"
local bar = require(
tostring(...):match(".*bling") .. ".widget.tabbar." .. bar_style
)
tabbed = {}
-- helper function to connect to the (un)focus signals
local function update_tabbar_from(c)
if not c or not c.bling_tabbed then
return
end
tabbed.update_tabbar(c.bling_tabbed)
end
-- used to change focused tab relative to the currently focused one
tabbed.iter = function(idx)
if not idx then
idx = 1
end
if not client.focus or not client.focus.bling_tabbed then
return
end
local tabobj = client.focus.bling_tabbed
local new_idx = (tabobj.focused_idx + idx) % #tabobj.clients
if new_idx == 0 then
new_idx = #tabobj.clients
end
tabbed.switch_to(tabobj, new_idx)
end
-- removes a given client from its tab object
tabbed.remove = function(c)
if not c or not c.bling_tabbed then
return
end
local tabobj = c.bling_tabbed
table.remove(tabobj.clients, tabobj.focused_idx)
if not beautiful.tabbar_disable then
awful.titlebar.hide(c, bar.position)
end
c.bling_tabbed = nil
c:disconnect_signal("focus", update_tabbar_from)
c:disconnect_signal("unfocus", update_tabbar_from)
awesome.emit_signal("bling::tabbed::client_removed", tabobj, c)
tabbed.switch_to(tabobj, 1)
end
-- removes the currently focused client from the tab object
tabbed.pop = function()
if not client.focus or not client.focus.bling_tabbed then
return
end
tabbed.remove(client.focus)
end
-- adds a client to a given tabobj
tabbed.add = function(c, tabobj)
if c.bling_tabbed then
tabbed.remove(c)
end
c:connect_signal("focus", update_tabbar_from)
c:connect_signal("unfocus", update_tabbar_from)
helpers.client.sync(c, tabobj.clients[tabobj.focused_idx])
tabobj.clients[#tabobj.clients + 1] = c
tabobj.focused_idx = #tabobj.clients
-- calls update even though switch_to calls update again
-- but the new client needs to have the tabobj property
-- before a clean switch can happen
tabbed.update(tabobj)
awesome.emit_signal("bling::tabbed::client_added", tabobj, c)
tabbed.switch_to(tabobj, #tabobj.clients)
end
-- use xwininfo to select one client and make it tab in the currently focused tab
tabbed.pick = function()
if not client.focus then
return
end
-- this function uses xwininfo to grab a client window id which is then
-- compared to all other clients window ids
local xwininfo_cmd =
[[ xwininfo | grep 'xwininfo: Window id:' | cut -d " " -f 4 ]]
awful.spawn.easy_async_with_shell(xwininfo_cmd, function(output)
for _, c in ipairs(client.get()) do
if tonumber(c.window) == tonumber(output) then
if not client.focus.bling_tabbed and not c.bling_tabbed then
tabbed.init(client.focus)
tabbed.add(c, client.focus.bling_tabbed)
end
if not client.focus.bling_tabbed and c.bling_tabbed then
tabbed.add(client.focus, c.bling_tabbed)
end
if client.focus.bling_tabbed and not c.bling_tabbed then
tabbed.add(c, client.focus.bling_tabbed)
end
-- TODO: Should also merge tabs when focus and picked
-- both are tab groups
end
end
end)
end
-- select a client by direction and make it tab in the currently focused tab
tabbed.pick_by_direction = function(direction)
local sel = client.focus
if not sel then
return
end
if not sel.bling_tabbed then
tabbed.init(sel)
end
local c = helpers.client.get_by_direction(direction)
if not c then
return
end
tabbed.add(c, sel.bling_tabbed)
end
-- use dmenu to select a client and make it tab in the currently focused tab
tabbed.pick_with_dmenu = function(dmenu_command)
if not client.focus then
return
end
if not dmenu_command then
dmenu_command = "rofi -dmenu -i"
end
-- get all clients from the current tag
-- ignores the case where multiple tags are selected
local t = awful.screen.focused().selected_tag
local list_clients = {}
local list_clients_string = ""
for idx, c in ipairs(t:clients()) do
if c.window ~= client.focus.window then
list_clients[#list_clients + 1] = c
if #list_clients ~= 1 then
list_clients_string = list_clients_string .. "\\n"
end
list_clients_string = list_clients_string
.. tostring(c.window)
.. " "
.. c.name
end
end
if #list_clients == 0 then
return
end
-- calls the actual dmenu
local xprop_cmd = [[ echo -e "]]
.. list_clients_string
.. [[" | ]]
.. dmenu_command
.. [[ | awk '{ print $1 }' ]]
awful.spawn.easy_async_with_shell(xprop_cmd, function(output)
for _, c in ipairs(list_clients) do
if tonumber(c.window) == tonumber(output) then
if not client.focus.bling_tabbed then
tabbed.init(client.focus)
end
local tabobj = client.focus.bling_tabbed
tabbed.add(c, tabobj)
end
end
end)
end
-- update everything about one tab object
tabbed.update = function(tabobj)
local currently_focused_c = tabobj.clients[tabobj.focused_idx]
-- update tabobj of each client and other things
for idx, c in ipairs(tabobj.clients) do
if c.valid then
c.bling_tabbed = tabobj
helpers.client.sync(c, currently_focused_c)
-- the following handles killing a client while the client is tabbed
c:connect_signal("unmanage", function(c)
tabbed.remove(c)
end)
end
end
-- Maybe remove if I'm the only one using it?
awesome.emit_signal("bling::tabbed::update", tabobj)
if not beautiful.tabbar_disable then
tabbed.update_tabbar(tabobj)
end
end
-- change focused tab by absolute index
tabbed.switch_to = function(tabobj, new_idx)
local old_focused_c = tabobj.clients[tabobj.focused_idx]
tabobj.focused_idx = new_idx
for idx, c in ipairs(tabobj.clients) do
if idx ~= new_idx then
helpers.client.turn_off(c)
else
helpers.client.turn_on(c)
c:raise()
if old_focused_c and old_focused_c.valid then
c:swap(old_focused_c)
end
helpers.client.sync(c, old_focused_c)
end
end
awesome.emit_signal("bling::tabbed::changed_focus", tabobj)
tabbed.update(tabobj)
end
tabbed.update_tabbar = function(tabobj)
local flexlist = bar.layout()
local tabobj_focused_client = tabobj.clients[tabobj.focused_idx]
local tabobj_is_focused = (client.focus == tabobj_focused_client)
-- itearte over all tabbed clients to create the widget tabbed list
for idx, c in ipairs(tabobj.clients) do
local buttons = gears.table.join(awful.button({}, 1, function()
tabbed.switch_to(tabobj, idx)
end))
local wid_temp = bar.create(c, (idx == tabobj.focused_idx), buttons,
not tabobj_is_focused)
flexlist:add(wid_temp)
end
-- add tabbar to each tabbed client (clients will be hided anyway)
if not beautiful.tabbar_disable then
for _, c in ipairs(tabobj.clients) do
local titlebar = awful.titlebar(c, {
bg = bar.bg_normal,
size = bar.size,
position = bar.position,
})
titlebar:setup({ layout = wibox.layout.flex.horizontal, flexlist })
end
end
end
tabbed.init = function(c)
local tabobj = {}
tabobj.clients = { c }
c:connect_signal("focus", update_tabbar_from)
c:connect_signal("unfocus", update_tabbar_from)
tabobj.focused_idx = 1
tabbed.update(tabobj)
end
if beautiful.tabbed_spawn_in_tab then
client.connect_signal("manage", function(c)
local s = awful.screen.focused()
local previous_client = awful.client.focus.history.get(s, 1)
if previous_client and previous_client.bling_tabbed then
tabbed.add(c, previous_client.bling_tabbed)
end
end)
end
return tabbed

View file

@ -1,56 +0,0 @@
--[[
This module makes use of cairo surfaces
For documentation take a look at the C docs:
https://www.cairographics.org/
They can be applied to lua by changing the naming conventions
and adjusting for the missing namespaces (and classes)
for example:
cairo_rectangle(cr, 1, 1, 1, 1) in C would be written as
cr:rectangle(1, 1, 1, 1) in lua
and
cairo_fill(cr) in C would be written as
cr:fill() in lua
--]]
local cairo = require("lgi").cairo
local gears = require("gears")
function create_tiled_wallpaper(str, s, args_table)
-- user input
args_table = args_table or {}
local fg = args_table.fg or "#ff0000"
local bg = args_table.bg or "#00ffff"
local offset_x = args_table.offset_x
local offset_y = args_table.offset_y
local font = args_table.font or "Hack"
local font_size = tonumber(args_table.font_size) or 16
local zickzack_bool = args_table.zickzack or false
local padding = args_table.padding or 100
-- create cairo image wallpaper
local img = cairo.ImageSurface(cairo.Format.RGB24, padding, padding)
cr = cairo.Context(img)
cr:set_source(gears.color(bg))
cr:paint()
cr:set_source(gears.color(fg))
cr:set_font_size(font_size)
cr:select_font_face(font)
if zickzack_bool then
cr:set_source(gears.color(fg))
cr:move_to(padding / 2 + font_size, padding / 2 + font_size)
cr:show_text(str)
end
cr:set_source(gears.color(fg))
cr:move_to(font_size, font_size)
cr:show_text(str)
-- tile cairo image
gears.wallpaper.tiled(img, s, { x = offset_x, y = offset_y })
end
return create_tiled_wallpaper

View file

@ -1,362 +0,0 @@
---------------------------------------------------------------------------
-- High-level declarative function for setting your wallpaper.
--
--
-- An easy way to setup a complex wallpaper with slideshow, random, schedule, extensibility.
--
-- @usage
-- local wallpaper = require("wallpaper")
-- -- A silly example
-- wallpaper.setup { -- I want a wallpaper
-- change_timer = 500, -- changing every 5 minutes
-- set_function = wallpaper.setters.random, -- in a random way
-- wallpaper = {"#abcdef",
-- "~/Pictures",
-- wallpaper.setters.awesome}, -- from this list (a color, a directory with pictures and the Awesome wallpaper)
-- recursive = false, -- do not read subfolders of "~/Pictures"
-- position = "centered", -- center it on the screen (for pictures)
-- scale = 2, -- 2 time bigger (for pictures)
-- }
--
-- @author Grumph
-- @copyright 2021 Grumph
--
---------------------------------------------------------------------------
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local setters = {}
--- Apply a wallpaper.
--
-- This function is a helper that will apply a wallpaper_object,
-- either using gears.wallpaper.set or gears.wallpaper.* higher level functions when applicable.
-- @param wallpaper_object A wallpaper object, either
-- a `pattern` (see `gears.wallpaper.set`)
-- a `surf` (see `gears.wallpaper.centered`)
-- a function that actually sets the wallpaper.
-- @tparam table args The argument table containing any of the arguments below.
-- @int[opt=nil] args.screen The screen to use (as used in `gears.wallpaper` functions)
-- @string[opt=nil or "centered"] args.position The `gears.wallpaper` position function to use.
-- Must be set when wallpaper is a file.
-- It can be `"centered"`, `"fit"`, `"tiled"` or `"maximized"`.
-- @string[opt=beautiful.bg_normal or "black"] args.background See `gears.wallpaper`.
-- @bool[opt=false] args.ignore_aspect See `gears.wallpaper`.
-- @tparam[opt={x=0,y=0}] table args.offset See `gears.wallpaper`.
-- @int[opt=1] args.scale See `gears.wallpaper`.
function apply(wallpaper_object, args)
args.background = args.background or beautiful.bg_normal or "black"
args.ignore_aspect = args.ignore_aspect or false -- false = keep aspect ratio
args.offset = args.offset or { x = 0, y = 0 }
args.scale = args.scale or 1
local positions = {
["centered"] = function(s)
gears.wallpaper.centered(
wallpaper_object,
s,
args.background,
args.scale
)
end,
["tiled"] = function(s)
gears.wallpaper.tiled(wallpaper_object, s, args.offset)
end,
["maximized"] = function(s)
gears.wallpaper.maximized(
wallpaper_object,
s,
args.ignore_aspect,
args.offset
)
end,
["fit"] = function(s)
gears.wallpaper.fit(wallpaper_object, s, args.background)
end,
}
local call_func = nil
if
type(wallpaper_object) == "string"
and gears.filesystem.file_readable(wallpaper_object)
then
-- path of an image file, we use a position function
local p = args.position or "centered"
call_func = positions[p]
elseif type(wallpaper_object) == "function" then
-- function
wallpaper_object(args)
elseif
(not gears.color.ensure_pango_color(wallpaper_object, nil))
and args.position
then
-- if the user sets a position function, wallpaper_object should be a cairo surface
call_func = positions[args.position]
else
gears.wallpaper.set(wallpaper_object)
end
if call_func then
call_func(args.screen)
end
end
--- Converts `args.wallpaper` to a list of `wallpaper_objects` readable by `apply` function).
--
-- @tparam table args The argument table containing the argument below.
-- @param[opt=`beautiful.wallpaper_path` or `"black"`] args.wallpaper A wallpaper object.
-- It can be a color or a cairo pattern (what `gears.wallpaper.set` understands),
-- a cairo suface (set with gears.wallpaper.set if `args.position` is nil, or with
-- `gears.wallpaper` position functions, see `args.position`),
-- a function similar to args.set_function that will effectively set a wallpaper (usually
-- with `gears.wallpaper` functions),
-- a path to a file,
-- path to a directory containing images,
-- or a list with any of the previous choices.
-- @tparam[opt=`{"jpg", "jpeg", "png", "bmp"}`] table args.image_formats A list of
-- file extensions to filter when `args.wallpaper` is a directory.
-- @bool[opt=true] args.recursive Either to recurse or not when `args.wallpaper` is a directory.
-- @treturn table A list of `wallpaper_objects` (what `apply` can read).
-- @see apply
function prepare_list(args)
args.image_formats = args.image_formats or { "jpg", "jpeg", "png", "bmp" }
args.recursive = args.recursive or true
local wallpapers = (args.wallpaper or beautiful.wallpaper_path or "black")
local res = {}
if type(wallpapers) ~= "table" then
wallpapers = { wallpapers }
end
for _, w in ipairs(wallpapers) do
-- w is either:
-- - a directory path (string)
-- - an image path or a color (string)
-- - a cairo surface or a cairo pattern
-- - a function for setting the wallpaper
if type(w) == "string" and gears.filesystem.dir_readable(w) then
local file_list = helpers.filesystem.list_directory_files(
w,
args.image_formats,
args.recursive
)
for _, f in ipairs(file_list) do
res[#res + 1] = w .. "/" .. f
end
else
res[#res + 1] = w
end
end
return res
end
local simple_index = 0
--- Set the next wallpaper in a list.
--
-- @tparam table args See `prepare_list` and `apply` arguments
-- @see apply
-- @see prepare_list
function setters.simple(args)
local wallpapers = prepare_list(args)
simple_index = (simple_index % #wallpapers) + 1
if type(args.screen) == 'table' then
for _,v in ipairs(args.screen) do
args.screen = v
apply(wallpapers[simple_index], args)
args.screen = nil
end
else
apply(wallpapers[simple_index], args)
end
end
--- Set a random wallpaper from a list.
--
-- @tparam table args See `prepare_list` and `apply` arguments
-- @see apply
-- @see prepare_list
function setters.random(args)
local wallpapers = prepare_list(args)
if type(args.screen) == 'table' then
for _,v in ipairs(args.screen) do
args.screen = v
apply(wallpapers[math.random(#wallpapers)], args)
args.screen = nil
end
else
apply(wallpapers[math.random(#wallpapers)], args)
end
end
local simple_schedule_object = nil
--- A schedule setter.
--
-- This simple schedule setter was freely inspired by [dynamic-wallpaper](https://github.com/manilarome/awesome-glorious-widgets/blob/master/dynamic-wallpaper/init.lua).
-- @tparam table args The argument table containing any of the arguments below.
-- @tparam table args.wallpaper The schedule table, with the form
-- {
-- ["HH:MM:SS"] = wallpaper,
-- ["HH:MM:SS"] = wallpaper2,
-- }
-- The wallpapers definition can be anything the `schedule_set_function` can read
-- (what you would place in `args.wallpaper` for this function),
-- @tparam[opt=`setters.simple`] function args.wallpaper_set_function The set_function used by default
function setters.simple_schedule(args)
local function update_wallpaper()
local fake_args = gears.table.join(args, {
wallpaper = args.wallpaper[simple_schedule_object.closest_lower_time],
})
simple_schedule_object.schedule_set_function(fake_args)
end
if not simple_schedule_object then
simple_schedule_object = {}
-- initialize the schedule object, so we don't do it for every call
simple_schedule_object.schedule_set_function = args.schedule_set_function
or setters.simple
-- we get the sorted time keys
simple_schedule_object.times = {}
for k in pairs(args.wallpaper) do
table.insert(simple_schedule_object.times, k)
end
table.sort(simple_schedule_object.times)
-- now we get the closest time which is below current time (the current applicable period)
local function update_timer()
local current_time = os.date("%H:%M:%S")
local next_time = simple_schedule_object.times[1]
simple_schedule_object.closest_lower_time =
simple_schedule_object.times[#simple_schedule_object.times]
for _, k in ipairs(simple_schedule_object.times) do
if k > current_time then
next_time = k
break
end
simple_schedule_object.closest_lower_time = k
end
simple_schedule_object.timer.timeout = helpers.time.time_diff(
next_time,
current_time
)
if simple_schedule_object.timer.timeout < 0 then
-- the next_time is the day after, so we add 24 hours to the timer
simple_schedule_object.timer.timeout = simple_schedule_object.timer.timeout
+ 86400
end
simple_schedule_object.timer:again()
update_wallpaper()
end
simple_schedule_object.timer = gears.timer({
callback = update_timer,
})
update_timer()
else
-- if called again (usually when the change_timer is set), we just change the wallpaper depending on current parameters
update_wallpaper()
end
end
--- Set the AWESOME wallpaper.
--
-- @tparam table args The argument table containing the argument below.
-- @param[opt=`beautiful.bg_normal`] args.colors.bg The bg color.
-- If the default is used, the color is darkened if `beautiful.bg_normal` is light
-- or lightned if `beautiful.bg_normal` is dark.
-- @param[opt=`beautiful.fg_normal`] args.colors.fg The fg color.
-- @param[opt=`beautiful.fg_focus`] args.colors.alt_fg The alt_fg color.
--
-- see beautiful.theme_assets.wallpaper
function setters.awesome_wallpaper(args)
local colors = {
bg = beautiful.bg_normal,
fg = beautiful.fg_normal,
alt_fg = beautiful.bg_focus,
}
colors.bg = helpers.color.is_dark(beautiful.bg_normal)
and helpers.color.lighten(colors.bg)
or helpers.color.darken(colors.bg)
if type(args.colors) == "table" then
colors.bg = args.colors.bg or colors.bg
colors.fg = args.colors.fg or colors.fg
colors.alt_fg = args.colors.alt_fg or colors.alt_fg
end
-- Generate wallpaper:
if not args.screen then
for s in screen do
gears.wallpaper.set(
beautiful.theme_assets.wallpaper(
colors.bg,
colors.fg,
colors.alt_fg,
s
)
)
end
else
gears.wallpaper.set(
beautiful.theme_assets.wallpaper(
colors.bg,
colors.fg,
colors.alt_fg,
args.screen
)
)
end
end
--- Setup a wallpaper.
--
-- @tparam table args Parameters for the wallpaper. It may also contain all parameters your `args.set_function` needs
-- @int[opt=nil] args.screen The screen to use (as used in `gears.wallpaper` functions)
-- @int[opt=nil] args.change_timer Time in seconds for wallpaper changes
-- @tparam[opt=`setters.awesome` or `setters.simple`] function args.set_function A function to set the wallpaper
-- It takes args as parameter (the same args as the setup function).
-- This function is called at `"request::wallpaper"` `screen` signals and at `args.change_timer` timeouts.
-- There is no obligation, but for consistency, the function should use `args.wallpaper` as a feeder.
-- If `args.wallpaper` is defined, the default function is `setters.simple`, else it will be `setters.awesome`.
--
-- @usage
-- local wallpaper = require("wallpaper")
-- wallpaper.setup {
-- change_timer = 631, -- Prime number is better
-- set_function = wallpaper.setters.random,
-- -- parameters for the random setter
-- wallpaper = '/data/pictures/wallpapers',
-- position = "maximized",
-- }
--
-- @see apply
-- @see prepare_list
-- @see setters.simple
function setup(args)
local config = args or {}
config.set_function = config.set_function
or (config.wallpaper and setters.simple or setters.awesome_wallpaper)
local function set_wallpaper(s)
if type(config.screen) ~= 'table' then
if config.screen and s and config.screen ~= s then return end
config.screen = s or config.screen
end
config.set_function(config)
end
if config.change_timer and config.change_timer > 0 then
gears.timer({
timeout = config.change_timer,
call_now = false,
autostart = true,
callback = function()
set_wallpaper()
end,
})
end
if awesome.version == "v4.3" or awesome.version == "4.3" then
awful.screen.connect_for_each_screen(set_wallpaper)
else
screen.connect_signal("request::wallpaper", set_wallpaper)
end
end
return {
setup = setup,
setters = setters,
apply = apply,
prepare_list = prepare_list,
}

View file

@ -1,128 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
-- It might actually swallow too much, that's why there is a filter option by classname
-- without the don't-swallow-list it would also swallow for example
-- file pickers or new firefox windows spawned by an already existing one
local window_swallowing_activated = false
-- you might want to add or remove applications here
local parent_filter_list = beautiful.parent_filter_list
or beautiful.dont_swallow_classname_list
or { "firefox", "Gimp", "Google-chrome" }
local child_filter_list = beautiful.child_filter_list
or beautiful.dont_swallow_classname_list or { }
-- for boolean values the or chain way to set the values breaks with 2 vars
-- and always defaults to true so i had to do this to se the right value...
local swallowing_filter = true
local filter_vars = { beautiful.swallowing_filter, beautiful.dont_swallow_filter_activated }
for _, var in pairs(filter_vars) do
swallowing_filter = var
end
-- check if element exist in table
-- returns true if it is
local function is_in_table(element, table)
local res = false
for _, value in pairs(table) do
if element:match(value) then
res = true
break
end
end
return res
end
-- if the swallowing filter is active checks the child and parent classes
-- against their filters
local function check_swallow(parent, child)
local res = true
if swallowing_filter then
local prnt = not is_in_table(parent, parent_filter_list)
local chld = not is_in_table(child, child_filter_list)
res = ( prnt and chld )
end
return res
end
-- async function to get the parent's pid
-- recieves a child process pid and a callback function
-- parent_pid in format "init(1)---ancestorA(pidA)---ancestorB(pidB)...---process(pid)"
function get_parent_pid(child_ppid, callback)
local ppid_cmd = string.format("pstree -A -p -s %s", child_ppid)
awful.spawn.easy_async(ppid_cmd, function(stdout, stderr, reason, exit_code)
-- primitive error checking
if stderr and stderr ~= "" then
callback(stderr)
return
end
local ppid = stdout
callback(nil, ppid)
end)
end
-- the function that will be connected to / disconnected from the spawn client signal
local function manage_clientspawn(c)
-- get the last focused window to check if it is a parent window
local parent_client = awful.client.focus.history.get(c.screen, 1)
if not parent_client then
return
elseif parent_client.type == "dialog" or parent_client.type == "splash" then
return
end
get_parent_pid(c.pid, function(err, ppid)
if err then
return
end
parent_pid = ppid
if
-- will search for "(parent_client.pid)" inside the parent_pid string
( tostring(parent_pid):find("("..tostring(parent_client.pid)..")") )
and check_swallow(parent_client.class, c.class)
then
c:connect_signal("unmanage", function()
if parent_client then
helpers.client.turn_on(parent_client)
helpers.client.sync(parent_client, c)
end
end)
helpers.client.sync(c, parent_client)
helpers.client.turn_off(parent_client)
end
end)
end
-- without the following functions that module would be autoloaded by require("bling")
-- a toggle window swallowing hotkey is also possible that way
local function start()
client.connect_signal("manage", manage_clientspawn)
window_swallowing_activated = true
end
local function stop()
client.disconnect_signal("manage", manage_clientspawn)
window_swallowing_activated = false
end
local function toggle()
if window_swallowing_activated then
stop()
else
start()
end
end
return {
start = start,
stop = stop,
toggle = toggle,
}

View file

@ -1,3 +0,0 @@
return {
playerctl = require(... .. ".playerctl"),
}

View file

@ -1,46 +0,0 @@
local awful = require("awful")
local gtimer = require("gears.timer")
local beautiful = require("beautiful")
local naughty = require("naughty")
-- Use CLI backend as default as it is supported on most if not all systems
local backend_config = beautiful.playerctl_backend or "playerctl_cli"
local backends = {
playerctl_cli = require(... .. ".playerctl_cli"),
playerctl_lib = require(... .. ".playerctl_lib"),
}
local backend = nil
local function enable_wrapper(args)
local open = naughty.action { name = "Open" }
open:connect_signal("invoked", function()
awful.spawn("xdg-open https://blingcorp.github.io/bling/#/signals/pctl")
end)
gtimer.delayed_call(function()
naughty.notify({
title = "Bling Error",
text = "Global signals are deprecated! Please take a look at the playerctl documentation.",
app_name = "Bling Error",
app_icon = "system-error",
actions = { open }
})
end)
backend_config = (args and args.backend) or backend_config
backend = backends[backend_config](args)
return backend
end
local function disable_wrapper()
backend:disable()
end
return {
lib = backends.playerctl_lib,
cli = backends.playerctl_cli,
enable = enable_wrapper,
disable = disable_wrapper
}

View file

@ -1,348 +0,0 @@
-- Playerctl signals
--
-- Provides:
-- metadata
-- title (string)
-- artist (string)
-- album_path (string)
-- album (string)
-- player_name (string)
-- position
-- interval_sec (number)
-- length_sec (number)
-- playback_status
-- playing (boolean)
-- volume
-- volume (number)
-- loop_status
-- loop_status (string)
-- shuffle
-- shuffle (bool)
-- no_players
-- (No parameters)
local awful = require("awful")
local gobject = require("gears.object")
local gtable = require("gears.table")
local gtimer = require("gears.timer")
local gstring = require("gears.string")
local beautiful = require("beautiful")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local setmetatable = setmetatable
local tonumber = tonumber
local ipairs = ipairs
local type = type
local capi = { awesome = awesome }
local playerctl = { mt = {} }
function playerctl:disable()
self._private.metadata_timer:stop()
self._private.metadata_timer = nil
awful.spawn.with_shell("killall playerctl")
end
function playerctl:pause(player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " pause")
else
awful.spawn.with_shell(self._private.cmd .. "pause")
end
end
function playerctl:play(player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " play")
else
awful.spawn.with_shell(self._private.cmd .. "play")
end
end
function playerctl:stop(player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " stop")
else
awful.spawn.with_shell(self._private.cmd .. "stop")
end
end
function playerctl:play_pause(player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " play-pause")
else
awful.spawn.with_shell(self._private.cmd .. "play-pause")
end
end
function playerctl:previous(player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " previous")
else
awful.spawn.with_shell(self._private.cmd .. "previous")
end
end
function playerctl:next(player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " next")
else
awful.spawn.with_shell(self._private.cmd .. "next")
end
end
function playerctl:set_loop_status(loop_status, player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " loop " .. loop_status)
else
awful.spawn.with_shell(self._private.cmd .. "loop " .. loop_status)
end
end
function playerctl:cycle_loop_status(player)
local function set_loop_status(loop_status)
if loop_status == "None" then
self:set_loop_status("Track")
elseif loop_status == "Track" then
self:set_loop_status("Playlist")
elseif loop_status == "Playlist" then
self:set_loop_status("None")
end
end
if player ~= nil then
awful.spawn.easy_async_with_shell("playerctl --player=" .. player .. " loop", function(stdout)
set_loop_status(stdout)
end)
else
set_loop_status(self._private.loop_status)
end
end
function playerctl:set_position(position, player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " position " .. position)
else
awful.spawn.with_shell(self._private.cmd .. "position " .. position)
end
end
function playerctl:set_shuffle(shuffle, player)
shuffle = shuffle and "on" or "off"
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " shuffle " .. shuffle)
else
awful.spawn.with_shell(self._private.cmd .. "shuffle " .. shuffle)
end
end
function playerctl:cycle_shuffle(player)
if player ~= nil then
awful.spawn.easy_async_with_shell("playerctl --player=" .. player .. " shuffle", function(stdout)
local shuffle = stdout == "on" and true or false
self:set_shuffle(not self._private.shuffle)
end)
else
self:set_shuffle(not self._private.shuffle)
end
end
function playerctl:set_volume(volume, player)
if player ~= nil then
awful.spawn.with_shell("playerctl --player=" .. player .. " volume " .. volume)
else
awful.spawn.with_shell(self._private.cmd .. "volume " .. volume)
end
end
local function emit_player_metadata(self)
local metadata_cmd = self._private.cmd .. "metadata --format 'title_{{title}}artist_{{artist}}art_url_{{mpris:artUrl}}player_name_{{playerName}}album_{{album}}' -F"
awful.spawn.with_line_callback(metadata_cmd, {
stdout = function(line)
local title = gstring.xml_escape(line:match('title_(.*)artist_')) or ""
local artist = gstring.xml_escape(line:match('artist_(.*)art_url_')) or ""
local art_url = line:match('art_url_(.*)player_name_') or ""
local player_name = line:match('player_name_(.*)album_') or ""
local album = gstring.xml_escape(line:match('album_(.*)')) or ""
art_url = art_url:gsub('%\n', '')
if player_name == "spotify" then
art_url = art_url:gsub("open.spotify.com", "i.scdn.co")
end
if self._private.metadata_timer
and self._private.metadata_timer.started
then
self._private.metadata_timer:stop()
end
self._private.metadata_timer = gtimer {
timeout = self.debounce_delay,
autostart = true,
single_shot = true,
callback = function()
if title and title ~= "" then
if art_url ~= "" then
local art_path = os.tmpname()
helpers.filesystem.save_image_async_curl(art_url, art_path, function()
self:emit_signal("metadata", title, artist, art_path, album, player_name)
capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, art_path)
end)
else
self:emit_signal("metadata", title, artist, "", album, player_name)
capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, "")
end
else
self:emit_signal("no_players")
capi.awesome.emit_signal("bling::playerctl::no_players")
end
end
}
collectgarbage("collect")
end,
})
end
local function emit_player_position(self)
local position_cmd = self._private.cmd .. "position"
local length_cmd = self._private.cmd .. "metadata mpris:length"
awful.widget.watch(position_cmd, self.interval, function(_, interval)
awful.spawn.easy_async_with_shell(length_cmd, function(length)
local length_sec = tonumber(length) -- in microseconds
local interval_sec = tonumber(interval) -- in seconds
if length_sec and interval_sec then
if interval_sec >= 0 and length_sec > 0 then
self:emit_signal("position", interval_sec, length_sec / 1000000)
capi.awesome.emit_signal("bling::playerctl::position", interval_sec, length_sec / 1000000)
end
end
end)
collectgarbage("collect")
end)
end
local function emit_player_playback_status(self)
local status_cmd = self._private.cmd .. "status -F"
awful.spawn.with_line_callback(status_cmd, {
stdout = function(line)
if line:find("Playing") then
self:emit_signal("playback_status", true)
capi.awesome.emit_signal("bling::playerctl::status", true)
else
self:emit_signal("playback_status", false)
capi.awesome.emit_signal("bling::playerctl::status", false)
end
end,
})
end
local function emit_player_volume(self)
local volume_cmd = self._private.cmd .. "volume -F"
awful.spawn.with_line_callback(volume_cmd, {
stdout = function(line)
self:emit_signal("volume", tonumber(line))
end,
})
end
local function emit_player_loop_status(self)
local loop_status_cmd = self._private.cmd .. "loop -F"
awful.spawn.with_line_callback(loop_status_cmd, {
stdout = function(line)
self._private.loop_status = line
self:emit_signal("loop_status", line:lower())
end,
})
end
local function emit_player_shuffle(self)
local shuffle_cmd = self._private.cmd .. "shuffle -F"
awful.spawn.with_line_callback(shuffle_cmd, {
stdout = function(line)
if line:find("On") then
self._private.shuffle = true
self:emit_signal("shuffle", true)
else
self._private.shuffle = false
self:emit_signal("shuffle", false)
end
end,
})
end
local function parse_args(self, args)
if args.player then
self._private.cmd = self._private.cmd .. "--player="
if type(args.player) == "string" then
self._private.cmd = self._private.cmd .. args.player .. " "
elseif type(args.player) == "table" then
for index, player in ipairs(args.player) do
self._private.cmd = self._private.cmd .. player
if index < #args.player then
self._private.cmd = self._private.cmd .. ","
else
self._private.cmd = self._private.cmd .. " "
end
end
end
end
if args.ignore then
self._private.cmd = self._private.cmd .. "--ignore-player="
if type(args.ignore) == "string" then
self._private.cmd = self._private.cmd .. args.ignore .. " "
elseif type(args.ignore) == "table" then
for index, player in ipairs(args.ignore) do
self._private.cmd = self._private.cmd .. player
if index < #args.ignore then
self._private.cmd = self._private.cmd .. ","
else
self._private.cmd = self._private.cmd .. " "
end
end
end
end
end
local function new(args)
args = args or {}
local ret = gobject{}
gtable.crush(ret, playerctl, true)
ret.interval = args.interval or beautiful.playerctl_position_update_interval or 1
ret.debounce_delay = args.debounce_delay or beautiful.playerctl_debounce_delay or 0.35
ret._private = {}
ret._private.metadata_timer = nil
ret._private.cmd = "playerctl "
parse_args(ret, args)
emit_player_metadata(ret)
emit_player_position(ret)
emit_player_playback_status(ret)
emit_player_volume(ret)
emit_player_loop_status(ret)
emit_player_shuffle(ret)
return ret
end
function playerctl.mt:__call(...)
return new(...)
end
-- On startup instead of on playerctl object init to make it
-- possible to have more than one of these running
awful.spawn.with_shell("killall playerctl")
return setmetatable(playerctl, playerctl.mt)

View file

@ -1,560 +0,0 @@
-- Playerctl signals
--
-- Provides:
-- metadata
-- title (string)
-- artist (string)
-- album_path (string)
-- album (string)
-- new (bool)
-- player_name (string)
-- position
-- interval_sec (number)
-- length_sec (number)
-- player_name (string)
-- playback_status
-- playing (boolean)
-- player_name (string)
-- seeked
-- position (number)
-- player_name (string)
-- volume
-- volume (number)
-- player_name (string)
-- loop_status
-- loop_status (string)
-- player_name (string)
-- shuffle
-- shuffle (boolean)
-- player_name (string)
-- exit
-- player_name (string)
-- no_players
-- (No parameters)
local awful = require("awful")
local gobject = require("gears.object")
local gtable = require("gears.table")
local gtimer = require("gears.timer")
local gstring = require("gears.string")
local beautiful = require("beautiful")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local setmetatable = setmetatable
local ipairs = ipairs
local pairs = pairs
local type = type
local capi = { awesome = awesome }
local playerctl = { mt = {} }
function playerctl:disable()
-- Restore default settings
self.ignore = {}
self.priority = {}
self.update_on_activity = true
self.interval = 1
self.debounce_delay = 0.35
-- Reset timers
self._private.manager = nil
self._private.metadata_timer:stop()
self._private.metadata_timer = nil
self._private.position_timer:stop()
self._private.position_timer = nil
-- Reset default values
self._private.last_position = -1
self._private.last_length = -1
self._private.last_player = nil
self._private.last_title = ""
self._private.last_artist = ""
self._private.last_artUrl = ""
end
function playerctl:pause(player)
player = player or self._private.manager.players[1]
if player then
player:pause()
end
end
function playerctl:play(player)
player = player or self._private.manager.players[1]
if player then
player:play()
end
end
function playerctl:stop(player)
player = player or self._private.manager.players[1]
if player then
player:stop()
end
end
function playerctl:play_pause(player)
player = player or self._private.manager.players[1]
if player then
player:play_pause()
end
end
function playerctl:previous(player)
player = player or self._private.manager.players[1]
if player then
player:previous()
end
end
function playerctl:next(player)
player = player or self._private.manager.players[1]
if player then
player:next()
end
end
function playerctl:set_loop_status(loop_status, player)
player = player or self._private.manager.players[1]
if player then
player:set_loop_status(loop_status)
end
end
function playerctl:cycle_loop_status(player)
player = player or self._private.manager.players[1]
if player then
if player.loop_status == "NONE" then
player:set_loop_status("TRACK")
elseif player.loop_status == "TRACK" then
player:set_loop_status("PLAYLIST")
elseif player.loop_status == "PLAYLIST" then
player:set_loop_status("NONE")
end
end
end
function playerctl:set_position(position, player)
player = player or self._private.manager.players[1]
if player then
player:set_position(position * 1000000)
end
end
function playerctl:set_shuffle(shuffle, player)
player = player or self._private.manager.players[1]
if player then
player:set_shuffle(shuffle)
end
end
function playerctl:cycle_shuffle(player)
player = player or self._private.manager.players[1]
if player then
player:set_shuffle(not player.shuffle)
end
end
function playerctl:set_volume(volume, player)
player = player or self._private.manager.players[1]
if player then
player:set_volume(volume)
end
end
function playerctl:get_manager()
return self._private.manager
end
function playerctl:get_active_player()
return self._private.manager.players[1]
end
function playerctl:get_player_of_name(name)
for _, player in ipairs(self._private.manager.players[1]) do
if player.name == name then
return player
end
end
return nil
end
local function emit_metadata_signal(self, title, artist, artUrl, album, new, player_name)
title = gstring.xml_escape(title)
artist = gstring.xml_escape(artist)
album = gstring.xml_escape(album)
-- Spotify client doesn't report its art URL's correctly...
if player_name == "spotify" then
artUrl = artUrl:gsub("open.spotify.com", "i.scdn.co")
end
if artUrl ~= "" then
local art_path = os.tmpname()
helpers.filesystem.save_image_async_curl(artUrl, art_path, function()
self:emit_signal("metadata", title, artist, art_path, album, new, player_name)
capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, art_path, player_name)
end)
else
capi.awesome.emit_signal("bling::playerctl::title_artist_album", title, artist, "", player_name)
self:emit_signal("metadata", title, artist, "", album, new, player_name)
end
end
local function metadata_cb(self, player, metadata)
if self.update_on_activity then
self._private.manager:move_player_to_top(player)
end
local data = metadata.value
local title = data["xesam:title"] or ""
local artist = data["xesam:artist"][1] or ""
for i = 2, #data["xesam:artist"] do
artist = artist .. ", " .. data["xesam:artist"][i]
end
local artUrl = data["mpris:artUrl"] or ""
local album = data["xesam:album"] or ""
if player == self._private.manager.players[1] then
self._private.active_player = player
-- Callback can be called even though values we care about haven't
-- changed, so check to see if they have
if
player ~= self._private.last_player
or title ~= self._private.last_title
or artist ~= self._private.last_artist
or artUrl ~= self._private.last_artUrl
then
if (title == "" and artist == "" and artUrl == "") then return end
if self._private.metadata_timer ~= nil and self._private.metadata_timer.started then
self._private.metadata_timer:stop()
end
self._private.metadata_timer = gtimer {
timeout = self.debounce_delay,
autostart = true,
single_shot = true,
callback = function()
emit_metadata_signal(self, title, artist, artUrl, album, true, player.player_name)
end
}
-- Re-sync with position timer when track changes
self._private.position_timer:again()
self._private.last_player = player
self._private.last_title = title
self._private.last_artist = artist
self._private.last_artUrl = artUrl
end
end
end
local function position_cb(self)
local player = self._private.manager.players[1]
if player then
local position = player:get_position() / 1000000
local length = (player.metadata.value["mpris:length"] or 0) / 1000000
if position ~= self._private.last_position or length ~= self._private.last_length then
capi.awesome.emit_signal("bling::playerctl::position", position, length, player.player_name)
self:emit_signal("position", position, length, player.player_name)
self._private.last_position = position
self._private.last_length = length
end
end
end
local function playback_status_cb(self, player, status)
if self.update_on_activity then
self._private.manager:move_player_to_top(player)
end
if player == self._private.manager.players[1] then
self._private.active_player = player
-- Reported as PLAYING, PAUSED, or STOPPED
if status == "PLAYING" then
self:emit_signal("playback_status", true, player.player_name)
capi.awesome.emit_signal("bling::playerctl::status", true, player.player_name)
else
self:emit_signal("playback_status", false, player.player_name)
capi.awesome.emit_signal("bling::playerctl::status", false, player.player_name)
end
end
end
local function seeked_cb(self, player, position)
if self.update_on_activity then
self._private.manager:move_player_to_top(player)
end
if player == self._private.manager.players[1] then
self._private.active_player = player
self:emit_signal("seeked", position / 1000000, player.player_name)
end
end
local function volume_cb(self, player, volume)
if self.update_on_activity then
self._private.manager:move_player_to_top(player)
end
if player == self._private.manager.players[1] then
self._private.active_player = player
self:emit_signal("volume", volume, player.player_name)
end
end
local function loop_status_cb(self, player, loop_status)
if self.update_on_activity then
self._private.manager:move_player_to_top(player)
end
if player == self._private.manager.players[1] then
self._private.active_player = player
self:emit_signal("loop_status", loop_status:lower(), player.player_name)
end
end
local function shuffle_cb(self, player, shuffle)
if self.update_on_activity then
self._private.manager:move_player_to_top(player)
end
if player == self._private.manager.players[1] then
self._private.active_player = player
self:emit_signal("shuffle", shuffle, player.player_name)
end
end
local function exit_cb(self, player)
if player == self._private.manager.players[1] then
self:emit_signal("exit", player.player_name)
end
end
-- Determine if player should be managed
local function name_is_selected(self, name)
if self.ignore[name.name] then
return false
end
if #self.priority > 0 then
for _, arg in pairs(self.priority) do
if arg == name.name or arg == "%any" then
return true
end
end
return false
end
return true
end
-- Create new player and connect it to callbacks
local function init_player(self, name)
if name_is_selected(self, name) then
local player = self._private.lgi_Playerctl.Player.new_from_name(name)
self._private.manager:manage_player(player)
player.on_metadata = function(player, metadata)
metadata_cb(self, player, metadata)
end
player.on_playback_status = function(player, playback_status)
playback_status_cb(self, player, playback_status)
end
player.on_seeked = function(player, position)
seeked_cb(self, player, position)
end
player.on_volume = function(player, volume)
volume_cb(self, player, volume)
end
player.on_loop_status = function(player, loop_status)
loop_status_cb(self, player, loop_status)
end
player.on_shuffle = function(player, shuffle_status)
shuffle_cb(self, player, shuffle_status)
end
player.on_exit = function(player, shuffle_status)
exit_cb(self, player)
end
-- Start position timer if its not already running
if not self._private.position_timer.started then
self._private.position_timer:again()
end
end
end
-- Determine if a player name comes before or after another according to the
-- priority order
local function player_compare_name(self, name_a, name_b)
local any_index = math.huge
local a_match_index = nil
local b_match_index = nil
if name_a == name_b then
return 0
end
for index, name in ipairs(self.priority) do
if name == "%any" then
any_index = (any_index == math.huge) and index or any_index
elseif name == name_a then
a_match_index = a_match_index or index
elseif name == name_b then
b_match_index = b_match_index or index
end
end
if not a_match_index and not b_match_index then
return 0
elseif not a_match_index then
return (b_match_index < any_index) and 1 or -1
elseif not b_match_index then
return (a_match_index < any_index) and -1 or 1
elseif a_match_index == b_match_index then
return 0
else
return (a_match_index < b_match_index) and -1 or 1
end
end
-- Sorting function used by manager if a priority order is specified
local function player_compare(self, a, b)
local player_a = self._private.lgi_Playerctl.Player(a)
local player_b = self._private.lgi_Playerctl.Player(b)
return player_compare_name(self, player_a.player_name, player_b.player_name)
end
local function get_current_player_info(self, player)
local title = player:get_title() or ""
local artist = player:get_artist() or ""
local artUrl = player:print_metadata_prop("mpris:artUrl") or ""
local album = player:get_album() or ""
emit_metadata_signal(self, title, artist, artUrl, album, false, player.player_name)
playback_status_cb(self, player, player.playback_status)
volume_cb(self, player, player.volume)
loop_status_cb(self, player, player.loop_status)
shuffle_cb(self, player, player.shuffle)
end
local function start_manager(self)
self._private.manager = self._private.lgi_Playerctl.PlayerManager()
if #self.priority > 0 then
self._private.manager:set_sort_func(function(a, b)
return player_compare(self, a, b)
end)
end
-- Timer to update track position at specified interval
self._private.position_timer = gtimer {
timeout = self.interval,
callback = function()
position_cb(self)
end,
}
-- Manage existing players on startup
for _, name in ipairs(self._private.manager.player_names) do
init_player(self, name)
end
if self._private.manager.players[1] then
get_current_player_info(self, self._private.manager.players[1])
end
local _self = self
-- Callback to manage new players
function self._private.manager:on_name_appeared(name)
init_player(_self, name)
end
function self._private.manager:on_player_appeared(player)
if player == self.players[1] then
_self._private.active_player = player
end
end
function self._private.manager:on_player_vanished(player)
if #self.players == 0 then
_self._private.metadata_timer:stop()
_self._private.position_timer:stop()
_self:emit_signal("no_players")
capi.awesome.emit_signal("bling::playerctl::no_players")
elseif player == _self._private.active_player then
_self._private.active_player = self.players[1]
get_current_player_info(_self, self.players[1])
end
end
end
local function parse_args(self, args)
self.ignore = {}
if type(args.ignore) == "string" then
self.ignore[args.ignore] = true
elseif type(args.ignore) == "table" then
for _, name in pairs(args.ignore) do
self.ignore[name] = true
end
end
self.priority = {}
if type(args.player) == "string" then
self.priority[1] = args.player
elseif type(args.player) == "table" then
self.priority = args.player
end
end
local function new(args)
args = args or {}
local ret = gobject{}
gtable.crush(ret, playerctl, true)
-- Grab settings from beautiful variables if not set explicitly
args.ignore = args.ignore or beautiful.playerctl_ignore
args.player = args.player or beautiful.playerctl_player
ret.update_on_activity = args.update_on_activity or
beautiful.playerctl_update_on_activity or true
ret.interval = args.interval or beautiful.playerctl_position_update_interval or 1
ret.debounce_delay = args.debounce_delay or beautiful.playerctl_debounce_delay or 0.35
parse_args(ret, args)
ret._private = {}
-- Metadata callback for title, artist, and album art
ret._private.last_player = nil
ret._private.last_title = ""
ret._private.last_artist = ""
ret._private.last_artUrl = ""
-- Track position callback
ret._private.last_position = -1
ret._private.last_length = -1
-- Grab playerctl library
ret._private.lgi_Playerctl = require("lgi").Playerctl
ret._private.manager = nil
ret._private.metadata_timer = nil
ret._private.position_timer = nil
-- Ensure main event loop has started before starting player manager
gtimer.delayed_call(function()
start_manager(ret)
end)
return ret
end
function playerctl.mt:__call(...)
return new(...)
end
return setmetatable(playerctl, playerctl.mt)

View file

@ -1,105 +0,0 @@
--[[ Bling theme variables template
This file has all theme variables of the bling module.
Every variable has a small comment on what it does.
You might just want to copy that whole part into your theme.lua and start adjusting from there.
--]]
-- LuaFormatter off
-- window swallowing
theme.dont_swallow_classname_list = { "firefox", "Gimp" } -- list of class names that should not be swallowed
theme.dont_swallow_filter_activated = true -- whether the filter above should be active
-- flash focus
theme.flash_focus_start_opacity = 0.6 -- the starting opacity
theme.flash_focus_step = 0.01 -- the step of animation
-- playerctl signal
theme.playerctl_backend = "playerctl_cli" -- backend to use
theme.playerctl_ignore = {} -- list of players to be ignored
theme.playerctl_player = {} -- list of players to be used in priority order
theme.playerctl_update_on_activity = true -- whether to prioritize the most recently active players or not
theme.playerctl_position_update_interval = 1 -- the update interval for fetching the position from playerctl
-- tabbed
theme.tabbed_spawn_in_tab = false -- whether a new client should spawn into the focused tabbing container
-- tabbar general
theme.tabbar_disable = false -- disable the tab bar entirely
theme.tabbar_ontop = false
theme.tabbar_radius = 0 -- border radius of the tabbar
theme.tabbar_style = "default" -- style of the tabbar ("default", "boxes" or "modern")
theme.tabbar_font = "Sans 11" -- font of the tabbar
theme.tabbar_size = 40 -- size of the tabbar
theme.tabbar_position = "top" -- position of the tabbar
theme.tabbar_bg_normal = "#000000" -- background color of the focused client on the tabbar
theme.tabbar_fg_normal = "#ffffff" -- foreground color of the focused client on the tabbar
theme.tabbar_bg_focus = "#1A2026" -- background color of unfocused clients on the tabbar
theme.tabbar_fg_focus = "#ff0000" -- foreground color of unfocused clients on the tabbar
theme.tabbar_bg_focus_inactive = nil -- background color of the focused client on the tabbar when inactive
theme.tabbar_fg_focus_inactive = nil -- foreground color of the focused client on the tabbar when inactive
theme.tabbar_bg_normal_inactive = nil -- background color of unfocused clients on the tabbar when inactive
theme.tabbar_fg_normal_inactive = nil -- foreground color of unfocused clients on the tabbar when inactive
-- mstab
theme.mstab_bar_disable = false -- disable the tabbar
theme.mstab_bar_ontop = false -- whether you want to allow the bar to be ontop of clients
theme.mstab_dont_resize_slaves = false -- whether the tabbed stack windows should be smaller than the
-- currently focused stack window (set it to true if you use
-- transparent terminals. False if you use shadows on solid ones
theme.mstab_bar_padding = "default" -- how much padding there should be between clients and your tabbar
-- by default it will adjust based on your useless gaps.
-- If you want a custom value. Set it to the number of pixels (int)
theme.mstab_border_radius = 0 -- border radius of the tabbar
theme.mstab_bar_height = 40 -- height of the tabbar
theme.mstab_tabbar_position = "top" -- position of the tabbar (mstab currently does not support left,right)
theme.mstab_tabbar_style = "default" -- style of the tabbar ("default", "boxes" or "modern")
-- defaults to the tabbar_style so only change if you want a
-- different style for mstab and tabbed
-- the following variables are currently only for the "modern" tabbar style
theme.tabbar_color_close = "#f9929b" -- changes the color of the close button
theme.tabbar_color_min = "#fbdf90" -- changes the color of the minimize button
theme.tabbar_color_float = "#ccaced" -- changes the color of the float button
-- tag preview widget
theme.tag_preview_widget_border_radius = 0 -- Border radius of the widget (With AA)
theme.tag_preview_client_border_radius = 0 -- Border radius of each client in the widget (With AA)
theme.tag_preview_client_opacity = 0.5 -- Opacity of each client
theme.tag_preview_client_bg = "#000000" -- The bg color of each client
theme.tag_preview_client_border_color = "#ffffff" -- The border color of each client
theme.tag_preview_client_border_width = 3 -- The border width of each client
theme.tag_preview_widget_bg = "#000000" -- The bg color of the widget
theme.tag_preview_widget_border_color = "#ffffff" -- The border color of the widget
theme.tag_preview_widget_border_width = 3 -- The border width of the widget
theme.tag_preview_widget_margin = 0 -- The margin of the widget
-- task preview widget
theme.task_preview_widget_border_radius = 0 -- Border radius of the widget (With AA)
theme.task_preview_widget_bg = "#000000" -- The bg color of the widget
theme.task_preview_widget_border_color = "#ffffff" -- The border color of the widget
theme.task_preview_widget_border_width = 3 -- The border width of the widget
theme.task_preview_widget_margin = 0 -- The margin of the widget
-- window switcher
theme.window_switcher_widget_bg = "#000000" -- The bg color of the widget
theme.window_switcher_widget_border_width = 3 -- The border width of the widget
theme.window_switcher_widget_border_radius = 0 -- The border radius of the widget
theme.window_switcher_widget_border_color = "#ffffff" -- The border color of the widget
theme.window_switcher_clients_spacing = 20 -- The space between each client item
theme.window_switcher_client_icon_horizontal_spacing = 5 -- The space between client icon and text
theme.window_switcher_client_width = 150 -- The width of one client widget
theme.window_switcher_client_height = 250 -- The height of one client widget
theme.window_switcher_client_margins = 10 -- The margin between the content and the border of the widget
theme.window_switcher_thumbnail_margins = 10 -- The margin between one client thumbnail and the rest of the widget
theme.thumbnail_scale = false -- If set to true, the thumbnails fit policy will be set to "fit" instead of "auto"
theme.window_switcher_name_margins = 10 -- The margin of one clients title to the rest of the widget
theme.window_switcher_name_valign = "center" -- How to vertically align one clients title
theme.window_switcher_name_forced_width = 200 -- The width of one title
theme.window_switcher_name_font = "Sans 11" -- The font of all titles
theme.window_switcher_name_normal_color = "#ffffff" -- The color of one title if the client is unfocused
theme.window_switcher_name_focus_color = "#ff0000" -- The color of one title if the client is focused
theme.window_switcher_icon_valign = "center" -- How to vertically align the one icon
theme.window_switcher_icon_width = 40 -- The width of one icon
-- LuaFormatter on

File diff suppressed because it is too large Load diff

View file

@ -1,656 +0,0 @@
---------------------------------------------------------------------------
--- Modified Prompt module.
-- @author Julien Danjou &lt;julien@danjou.info&gt;
-- @copyright 2008 Julien Danjou
---------------------------------------------------------------------------
local akey = require("awful.key")
local keygrabber = require("awful.keygrabber")
local gobject = require("gears.object")
local gdebug = require('gears.debug')
local gtable = require("gears.table")
local gcolor = require("gears.color")
local gstring = require("gears.string")
local gfs = require("gears.filesystem")
local wibox = require("wibox")
local beautiful = require("beautiful")
local io = io
local table = table
local math = math
local ipairs = ipairs
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
local capi = { selection = selection }
local prompt = { mt = {} }
--- Private data
local data = {}
data.history = {}
local function itera(inc,a, i)
i = i + inc
local v = a[i]
if v then return i,v end
end
local function history_check_load(id, max)
if id and id ~= "" and not data.history[id] then
data.history[id] = { max = 50, table = {} }
if max then
data.history[id].max = max
end
local f = io.open(id, "r")
if not f then return end
-- Read history file
for line in f:lines() do
if gtable.hasitem(data.history[id].table, line) == nil then
table.insert(data.history[id].table, line)
if #data.history[id].table >= data.history[id].max then
break
end
end
end
f:close()
end
end
local function is_word_char(c)
if string.find(c, "[{[(,.:;_-+=@/ ]") then
return false
else
return true
end
end
local function cword_start(s, pos)
local i = pos
if i > 1 then
i = i - 1
end
while i >= 1 and not is_word_char(s:sub(i, i)) do
i = i - 1
end
while i >= 1 and is_word_char(s:sub(i, i)) do
i = i - 1
end
if i <= #s then
i = i + 1
end
return i
end
local function cword_end(s, pos)
local i = pos
while i <= #s and not is_word_char(s:sub(i, i)) do
i = i + 1
end
while i <= #s and is_word_char(s:sub(i, i)) do
i = i + 1
end
return i
end
local function history_save(id)
if data.history[id] then
gfs.make_parent_directories(id)
local f = io.open(id, "w")
if not f then
gdebug.print_warning("Failed to write the history to "..id)
return
end
for i = 1, math.min(#data.history[id].table, data.history[id].max) do
f:write(data.history[id].table[i] .. "\n")
end
f:close()
end
end
local function history_items(id)
if data.history[id] then
return #data.history[id].table
else
return -1
end
end
local function history_add(id, command)
if data.history[id] and command ~= "" then
local index = gtable.hasitem(data.history[id].table, command)
if index == nil then
table.insert(data.history[id].table, command)
-- Do not exceed our max_cmd
if #data.history[id].table > data.history[id].max then
table.remove(data.history[id].table, 1)
end
history_save(id)
else
-- Bump this command to the end of history
table.remove(data.history[id].table, index)
table.insert(data.history[id].table, command)
history_save(id)
end
end
end
local function have_multibyte_char_at(text, position)
return text:sub(position, position):wlen() == -1
end
local function prompt_text_with_cursor(args)
local char, spacer, text_start, text_end, ret
local text = args.text or ""
local _prompt = args.prompt or ""
local underline = args.cursor_ul or "none"
if args.select_all then
if #text == 0 then char = " " else char = gstring.xml_escape(text) end
spacer = " "
text_start = ""
text_end = ""
elseif #text < args.cursor_pos then
char = " "
spacer = ""
text_start = gstring.xml_escape(text)
text_end = ""
else
local offset = 0
if have_multibyte_char_at(text, args.cursor_pos) then
offset = 1
end
char = gstring.xml_escape(text:sub(args.cursor_pos, args.cursor_pos + offset))
spacer = " "
text_start = gstring.xml_escape(text:sub(1, args.cursor_pos - 1))
text_end = gstring.xml_escape(text:sub(args.cursor_pos + 1 + offset))
end
local cursor_color = gcolor.ensure_pango_color(args.cursor_color)
local text_color = gcolor.ensure_pango_color(args.text_color)
if args.highlighter then
text_start, text_end = args.highlighter(text_start, text_end)
end
ret = _prompt .. text_start .. "<span background=\"" .. cursor_color ..
"\" foreground=\"" .. text_color .. "\" underline=\"" .. underline ..
"\">" .. char .. "</span>" .. text_end .. spacer
return ret
end
local function update(self)
self.textbox:set_font(self.font)
self.textbox:set_markup(prompt_text_with_cursor{
text = self.command, text_color = self.fg_cursor, cursor_color = self.bg_cursor,
cursor_pos = self._private_cur_pos, cursor_ul = self.ul_cursor, select_all = self.select_all,
prompt = self.prompt, highlighter = self.highlighter })
end
local function exec(self, cb, command_to_history)
self.textbox:set_markup("")
history_add(self.history_path, command_to_history)
keygrabber.stop(self._private.grabber)
if cb then cb(self.command) end
if self.done_callback then
self.done_callback()
end
end
function prompt:start()
-- The cursor position
if self.reset_on_stop == true or self._private_cur_pos == nil then
self._private_cur_pos = (self.select_all and 1) or self.text:wlen() + 1
end
if self.reset_on_stop == true then self.text = "" self.command = "" end
self.textbox:set_font(self.font)
self.textbox:set_markup(prompt_text_with_cursor{
text = self.reset_on_stop and self.text or self.command, text_color = self.fg_cursor, cursor_color = self.bg_cursor,
cursor_pos = self._private_cur_pos, cursor_ul = self.ul_cursor, select_all = self.select_all,
prompt = self.prompt, highlighter = self.highlighter})
self._private.search_term = nil
history_check_load(self.history_path, self.history_max)
local history_index = history_items(self.history_path) + 1
-- The completion element to use on completion request.
local ncomp = 1
local command_before_comp
local cur_pos_before_comp
self._private.grabber = keygrabber.run(function(modifiers, key, event)
-- Convert index array to hash table
local mod = {}
for _, v in ipairs(modifiers) do mod[v] = true end
if event ~= "press" then
if self.keyreleased_callback then
self.keyreleased_callback(mod, key, self.command)
end
return
end
-- Call the user specified callback. If it returns true as
-- the first result then return from the function. Treat the
-- second and third results as a new command and new prompt
-- to be set (if provided)
if self.keypressed_callback then
local user_catched, new_command, new_prompt =
self.keypressed_callback(mod, key, self.command)
if new_command or new_prompt then
if new_command then
self.command = new_command
end
if new_prompt then
self.prompt = new_prompt
end
update(self)
end
if user_catched then
if self.changed_callback then
self.changed_callback(self.command)
end
return
end
end
local filtered_modifiers = {}
-- User defined cases
if self.hooks[key] then
-- Remove caps and num lock
for _, m in ipairs(modifiers) do
if not gtable.hasitem(akey.ignore_modifiers, m) then
table.insert(filtered_modifiers, m)
end
end
for _,v in ipairs(self.hooks[key]) do
if #filtered_modifiers == #v[1] then
local match = true
for _,v2 in ipairs(v[1]) do
match = match and mod[v2]
end
if match then
local cb
local ret, quit = v[3](self.command)
local original_command = self.command
-- Support both a "simple" and a "complex" way to
-- control if the prompt should quit.
quit = quit == nil and (ret ~= true) or (quit~=false)
-- Allow the callback to change the command
self.command = (ret ~= true) and ret or self.command
-- Quit by default, but allow it to be disabled
if ret and type(ret) ~= "boolean" then
cb = self.exe_callback
if not quit then
self._private_cur_pos = ret:wlen() + 1
update(self)
end
elseif quit then
-- No callback.
cb = function() end
end
-- Execute the callback
if cb then
exec(self, cb, original_command)
end
return
end
end
end
end
-- Get out cases
if (mod.Control and (key == "c" or key == "g"))
or (not mod.Control and key == "Escape") then
self:stop()
return false
elseif (mod.Control and (key == "j" or key == "m"))
-- or (not mod.Control and key == "Return")
-- or (not mod.Control and key == "KP_Enter")
then
exec(self, self.exe_callback, self.command)
-- We already unregistered ourselves so we don't want to return
-- true, otherwise we may unregister someone else.
return
end
-- Control cases
if mod.Control then
self.select_all = nil
if key == "v" then
local selection = capi.selection()
if selection then
-- Remove \n
local n = selection:find("\n")
if n then
selection = selection:sub(1, n - 1)
end
self.command = self.command:sub(1, self._private_cur_pos - 1) .. selection .. self.command:sub(self._private_cur_pos)
self._private_cur_pos = self._private_cur_pos + #selection
end
elseif key == "a" then
self._private_cur_pos = 1
elseif key == "b" then
if self._private_cur_pos > 1 then
self._private_cur_pos = self._private_cur_pos - 1
if have_multibyte_char_at(self.command, self._private_cur_pos) then
self._private_cur_pos = self._private_cur_pos - 1
end
end
elseif key == "d" then
if self._private_cur_pos <= #self.command then
self.command = self.command:sub(1, self._private_cur_pos - 1) .. self.command:sub(self._private_cur_pos + 1)
end
elseif key == "p" then
if history_index > 1 then
history_index = history_index - 1
self.command = data.history[self.history_path].table[history_index]
self._private_cur_pos = #self.command + 2
end
elseif key == "n" then
if history_index < history_items(self.history_path) then
history_index = history_index + 1
self.command = data.history[self.history_path].table[history_index]
self._private_cur_pos = #self.command + 2
elseif history_index == history_items(self.history_path) then
history_index = history_index + 1
self.command = ""
self._private_cur_pos = 1
end
elseif key == "e" then
self._private_cur_pos = #self.command + 1
elseif key == "r" then
self._private.search_term = self._private.search_term or self.command:sub(1, self._private_cur_pos - 1)
for i,v in (function(a,i) return itera(-1,a,i) end), data.history[self.history_path].table, history_index do
if v:find(self._private.search_term,1,true) ~= nil then
self.command=v
history_index=i
self._private_cur_pos=#self.command+1
break
end
end
elseif key == "s" then
self._private.search_term = self._private.search_term or self.command:sub(1, self._private_cur_pos - 1)
for i,v in (function(a,i) return itera(1,a,i) end), data.history[self.history_path].table, history_index do
if v:find(self._private.search_term,1,true) ~= nil then
self.command=v
history_index=i
self._private_cur_pos=#self.command+1
break
end
end
elseif key == "f" then
if self._private_cur_pos <= #self.command then
if have_multibyte_char_at(self.command, self._private_cur_pos) then
self._private_cur_pos = self._private_cur_pos + 2
else
self._private_cur_pos = self._private_cur_pos + 1
end
end
elseif key == "h" then
if self._private_cur_pos > 1 then
local offset = 0
if have_multibyte_char_at(self.command, self._private_cur_pos - 1) then
offset = 1
end
self.command = self.command:sub(1, self._private_cur_pos - 2 - offset) .. self.command:sub(self._private_cur_pos)
self._private_cur_pos = self._private_cur_pos - 1 - offset
end
elseif key == "k" then
self.command = self.command:sub(1, self._private_cur_pos - 1)
elseif key == "u" then
self.command = self.command:sub(self._private_cur_pos, #self.command)
self._private_cur_pos = 1
elseif key == "Prior" then
self._private.search_term = self.command:sub(1, self._private_cur_pos - 1) or ""
for i,v in (function(a,i) return itera(-1,a,i) end), data.history[self.history_path].table, history_index do
if v:find(self._private.search_term,1,true) == 1 then
self.command=v
history_index=i
break
end
end
elseif key == "Next" then
self._private.search_term = self.command:sub(1, self._private_cur_pos - 1) or ""
for i,v in (function(a,i) return itera(1,a,i) end), data.history[self.history_path].table, history_index do
if v:find(self._private.search_term,1,true) == 1 then
self.command=v
history_index=i
break
end
end
elseif key == "w" or key == "BackSpace" then
local wstart = 1
local wend = 1
local cword_start_pos = 1
local cword_end_pos = 1
while wend < self._private_cur_pos do
wend = self.command:find("[{[(,.:;_-+=@/ ]", wstart)
if not wend then wend = #self.command + 1 end
if self._private_cur_pos >= wstart and self._private_cur_pos <= wend + 1 then
cword_start_pos = wstart
cword_end_pos = self._private_cur_pos - 1
break
end
wstart = wend + 1
end
self.command = self.command:sub(1, cword_start_pos - 1) .. self.command:sub(cword_end_pos + 1)
self._private_cur_pos = cword_start_pos
elseif key == "Delete" then
-- delete from history only if:
-- we are not dealing with a new command
-- the user has not edited an existing entry
if self.command == data.history[self.history_path].table[history_index] then
table.remove(data.history[self.history_path].table, history_index)
if history_index <= history_items(self.history_path) then
self.command = data.history[self.history_path].table[history_index]
self._private_cur_pos = #self.command + 2
elseif history_index > 1 then
history_index = history_index - 1
self.command = data.history[self.history_path].table[history_index]
self._private_cur_pos = #self.command + 2
else
self.command = ""
self._private_cur_pos = 1
end
end
end
elseif mod.Mod1 or mod.Mod3 then
if key == "b" then
self._private_cur_pos = cword_start(self.command, self._private_cur_pos)
elseif key == "f" then
self._private_cur_pos = cword_end(self.command, self._private_cur_pos)
elseif key == "d" then
self.command = self.command:sub(1, self._private_cur_pos - 1) .. self.command:sub(cword_end(self.command, self._private_cur_pos))
elseif key == "BackSpace" then
local wstart = cword_start(self.command, self._private_cur_pos)
self.command = self.command:sub(1, wstart - 1) .. self.command:sub(self._private_cur_pos)
self._private_cur_pos = wstart
end
else
if self.completion_callback then
if key == "Tab" or key == "ISO_Left_Tab" then
if key == "ISO_Left_Tab" or mod.Shift then
if ncomp == 1 then return end
if ncomp == 2 then
self.command = command_before_comp
self.textbox:set_font(self.font)
self.textbox:set_markup(prompt_text_with_cursor{
text = command_before_comp, text_color = self.fg_cursor, cursor_color = self.bg_cursor,
cursor_pos = self._private_cur_pos, cursor_ul = self.ul_cursor, select_all = self.select_all,
prompt = self.prompt })
self._private_cur_pos = cur_pos_before_comp
ncomp = 1
return
end
ncomp = ncomp - 2
elseif ncomp == 1 then
command_before_comp = self.command
cur_pos_before_comp = self._private_cur_pos
end
local matches
self.command, self._private_cur_pos, matches = self.completion_callback(command_before_comp, cur_pos_before_comp, ncomp)
ncomp = ncomp + 1
key = ""
-- execute if only one match found and autoexec flag set
if matches and #matches == 1 and args.autoexec then
exec(self, self.exe_callback)
return
end
elseif key ~= "Shift_L" and key ~= "Shift_R" then
ncomp = 1
end
end
-- Typin cases
if mod.Shift and key == "Insert" then
local selection = capi.selection()
if selection then
-- Remove \n
local n = selection:find("\n")
if n then
selection = selection:sub(1, n - 1)
end
self.command = self.command:sub(1, self._private_cur_pos - 1) .. selection .. self.command:sub(self._private_cur_pos)
self._private_cur_pos = self._private_cur_pos + #selection
end
elseif key == "Home" then
self._private_cur_pos = 1
elseif key == "End" then
self._private_cur_pos = #self.command + 1
elseif key == "BackSpace" then
if self._private_cur_pos > 1 then
local offset = 0
if have_multibyte_char_at(self.command, self._private_cur_pos - 1) then
offset = 1
end
self.command = self.command:sub(1, self._private_cur_pos - 2 - offset) .. self.command:sub(self._private_cur_pos)
self._private_cur_pos = self._private_cur_pos - 1 - offset
end
elseif key == "Delete" then
self.command = self.command:sub(1, self._private_cur_pos - 1) .. self.command:sub(self._private_cur_pos + 1)
elseif key == "Left" then
self._private_cur_pos = self._private_cur_pos - 1
elseif key == "Right" then
self._private_cur_pos = self._private_cur_pos + 1
elseif key == "Prior" then
if history_index > 1 then
history_index = history_index - 1
self.command = data.history[self.history_path].table[history_index]
self._private_cur_pos = #self.command + 2
end
elseif key == "Next" then
if history_index < history_items(self.history_path) then
history_index = history_index + 1
self.command = data.history[self.history_path].table[history_index]
self._private_cur_pos = #self.command + 2
elseif history_index == history_items(self.history_path) then
history_index = history_index + 1
self.command = ""
self._private_cur_pos = 1
end
else
-- wlen() is UTF-8 aware but #key is not,
-- so check that we have one UTF-8 char but advance the cursor of # position
if key:wlen() == 1 then
if self.select_all then self.command = "" end
self.command = self.command:sub(1, self._private_cur_pos - 1) .. key .. self.command:sub(self._private_cur_pos)
self._private_cur_pos = self._private_cur_pos + #key
end
end
if self._private_cur_pos < 1 then
self._private_cur_pos = 1
elseif self._private_cur_pos > #self.command + 1 then
self._private_cur_pos = #self.command + 1
end
self.select_all = nil
end
update(self)
if self.changed_callback then
self.changed_callback(self.command)
end
end)
end
function prompt:stop()
keygrabber.stop(self._private.grabber)
history_save(self.history_path)
if self.done_callback then self.done_callback() end
return false
end
local function new(args)
args = args or {}
args.command = args.text or ""
args.prompt = args.prompt or ""
args.text = args.text or ""
args.font = args.font or beautiful.prompt_font or beautiful.font
args.bg_cursor = args.bg_cursor or beautiful.prompt_bg_cursor or beautiful.bg_focus or "white"
args.fg_cursor = args.fg_cursor or beautiful.prompt_fg_cursor or beautiful.fg_focus or "black"
args.ul_cursor = args.ul_cursor or nil
args.reset_on_stop = args.reset_on_stop == nil and true or args.reset_on_stop
args.select_all = args.select_all or nil
args.highlighter = args.highlighter or nil
args.hooks = args.hooks or {}
args.keypressed_callback = args.keypressed_callback or nil
args.changed_callback = args.changed_callback or nil
args.done_callback = args.done_callback or nil
args.history_max = args.history_max or nil
args.history_path = args.history_path or nil
args.completion_callback = args.completion_callback or nil
args.exe_callback = args.exe_callback or nil
args.textbox = args.textbox or wibox.widget.textbox()
-- Build the hook map
local hooks = {}
for _,v in ipairs(args.hooks) do
if #v == 3 then
local _,key,callback = unpack(v)
if type(callback) == "function" then
hooks[key] = hooks[key] or {}
hooks[key][#hooks[key]+1] = v
else
gdebug.print_warning("The hook's 3rd parameter has to be a function.")
end
else
gdebug.print_warning("The hook has to have 3 parameters.")
end
end
args.hooks = hooks
local ret = gobject({})
ret._private = {}
gtable.crush(ret, prompt)
gtable.crush(ret, args)
return ret
end
function prompt.mt:__call(...)
return new(...)
end
return setmetatable(prompt, prompt.mt)

View file

@ -1,7 +0,0 @@
return {
tag_preview = require(... .. ".tag_preview"),
task_preview = require(... .. ".task_preview"),
window_switcher = require(... .. ".window_switcher"),
tabbed_misc = require(... .. ".tabbed_misc"),
app_launcher = require(... .. ".app_launcher"),
}

View file

@ -1,57 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local bg_normal = beautiful.tabbar_bg_normal or beautiful.bg_normal or "#ffffff"
local fg_normal = beautiful.tabbar_fg_normal or beautiful.fg_normal or "#000000"
local bg_focus = beautiful.tabbar_bg_focus or beautiful.bg_focus or "#000000"
local fg_focus = beautiful.tabbar_fg_focus or beautiful.fg_focus or "#ffffff"
local bg_focus_inactive = beautiful.tabbar_bg_focus_inactive or bg_focus
local fg_focus_inactive = beautiful.tabbar_fg_focus_inactive or fg_focus
local bg_normal_inactive = beautiful.tabbar_bg_normal_inactive or bg_normal
local fg_normal_inactive = beautiful.tabbar_fg_normal_inactive or fg_normal
local font = beautiful.tabbar_font or beautiful.font or "Hack 15"
local size = beautiful.tabbar_size or 40
local position = beautiful.tabbar_position or "bottom"
local function create(c, focused_bool, buttons, inactive_bool)
local bg_temp = inactive_bool and bg_normal_inactive or bg_normal
local fg_temp = inactive_bool and fg_normal_inactive or fg_normal
if focused_bool then
bg_temp = inactive_bool and bg_focus_inactive or bg_focus
fg_temp = inactive_bool and fg_focus_inactive or fg_focus
end
local wid_temp = wibox.widget({
{
{
awful.widget.clienticon(c),
left = 10,
right = 10,
bottom = 10,
top = 10,
widget = wibox.container.margin(),
},
widget = wibox.container.place(),
},
buttons = buttons,
bg = bg_temp,
widget = wibox.container.background(),
})
return wid_temp
end
local layout = wibox.layout.fixed.horizontal
if position == "left" or position == "right" then
layout = wibox.layout.fixed.vertical
end
return {
layout = layout,
create = create,
position = position,
size = size,
bg_normal = bg_normal,
bg_focus = bg_normal,
}

View file

@ -1,60 +0,0 @@
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local bg_normal = beautiful.tabbar_bg_normal or beautiful.bg_normal or "#ffffff"
local fg_normal = beautiful.tabbar_fg_normal or beautiful.fg_normal or "#000000"
local bg_focus = beautiful.tabbar_bg_focus or beautiful.bg_focus or "#000000"
local fg_focus = beautiful.tabbar_fg_focus or beautiful.fg_focus or "#ffffff"
local bg_focus_inactive = beautiful.tabbar_bg_focus_inactive or bg_focus
local fg_focus_inactive = beautiful.tabbar_fg_focus_inactive or fg_focus
local bg_normal_inactive = beautiful.tabbar_bg_normal_inactive or bg_normal
local fg_normal_inactive = beautiful.tabbar_fg_normal_inactive or fg_normal
local font = beautiful.tabbar_font or beautiful.font or "Hack 15"
local size = beautiful.tabbar_size or 20
local position = beautiful.tabbar_position or "top"
local function create(c, focused_bool, buttons, inactive_bool)
local flexlist = wibox.layout.flex.horizontal()
local title_temp = c.name or c.class or "-"
local bg_temp = inactive_bool and bg_normal_inactive or bg_normal
local fg_temp = inactive_bool and fg_normal_inactive or fg_normal
if focused_bool then
bg_temp = inactive_bool and bg_focus_inactive or bg_focus
fg_temp = inactive_bool and fg_focus_inactive or fg_focus
end
local text_temp = wibox.widget.textbox()
text_temp.align = "center"
text_temp.valign = "center"
text_temp.font = font
text_temp.markup = "<span foreground='"
.. fg_temp
.. "'>"
.. title_temp
.. "</span>"
c:connect_signal("property::name", function(_)
local title_temp = c.name or c.class or "-"
text_temp.markup = "<span foreground='"
.. fg_temp
.. "'>"
.. title_temp
.. "</span>"
end)
local wid_temp = wibox.widget({
text_temp,
buttons = buttons,
bg = bg_temp,
widget = wibox.container.background(),
})
return wid_temp
end
return {
layout = wibox.layout.flex.horizontal,
create = create,
position = position,
size = size,
bg_normal = bg_normal,
bg_focus = bg_focus,
}

View file

@ -1,271 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local bg_normal = beautiful.tabbar_bg_normal or beautiful.bg_normal or "#ffffff"
local fg_normal = beautiful.tabbar_fg_normal or beautiful.fg_normal or "#000000"
local bg_focus = beautiful.tabbar_bg_focus or beautiful.bg_focus or "#000000"
local fg_focus = beautiful.tabbar_fg_focus or beautiful.fg_focus or "#ffffff"
local bg_focus_inactive = beautiful.tabbar_bg_focus_inactive or bg_focus
local fg_focus_inactive = beautiful.tabbar_fg_focus_inactive or fg_focus
local bg_normal_inactive = beautiful.tabbar_bg_normal_inactive or bg_normal
local fg_normal_inactive = beautiful.tabbar_fg_normal_inactive or fg_normal
local font = beautiful.tabbar_font or beautiful.font or "Hack 15"
local size = beautiful.tabbar_size or dpi(40)
local border_radius = beautiful.mstab_border_radius
or beautiful.border_radius
or 6
local position = beautiful.tabbar_position or "top"
local close_color = beautiful.tabbar_color_close
or beautiful.xcolor1
or "#f9929b"
local min_color = beautiful.tabbar_color_min or beautiful.xcolor3 or "#fbdf90"
local float_color = beautiful.tabbar_color_float
or beautiful.xcolor5
or "#ccaced"
-- Helper to create buttons
local function create_title_button(c, color_focus, color_unfocus)
local tb_color = wibox.widget({
wibox.widget.textbox(),
forced_width = dpi(8),
forced_height = dpi(8),
bg = color_focus,
shape = gears.shape.circle,
widget = wibox.container.background,
})
local tb = wibox.widget({
tb_color,
width = dpi(25),
height = dpi(25),
strategy = "min",
layout = wibox.layout.constraint,
})
local function update()
if client.focus == c then
tb_color.bg = color_focus
else
tb_color.bg = color_unfocus
end
end
update()
c:connect_signal("focus", update)
c:connect_signal("unfocus", update)
tb:connect_signal("mouse::enter", function()
tb_color.bg = color_focus .. "70"
end)
tb:connect_signal("mouse::leave", function()
tb_color.bg = color_focus
end)
tb.visible = true
return tb
end
local function create(c, focused_bool, buttons, inactive_bool)
-- local flexlist = wibox.layout.flex.horizontal()
local title_temp = c.name or c.class or "-"
local bg_temp = inactive_bool and bg_normal_inactive or bg_normal
local fg_temp = inactive_bool and fg_normal_inactive or fg_normal
if focused_bool then
bg_temp = inactive_bool and bg_focus_inactive or bg_focus
fg_temp = inactive_bool and fg_focus_inactive or fg_focus
end
local text_temp = wibox.widget.textbox()
text_temp.align = "center"
text_temp.valign = "center"
text_temp.font = font
text_temp.markup = "<span foreground='"
.. fg_temp
.. "'>"
.. title_temp
.. "</span>"
c:connect_signal("property::name", function(_)
local title_temp = c.name or c.class or "-"
text_temp.markup = "<span foreground='"
.. fg_temp
.. "'>"
.. title_temp
.. "</span>"
end)
local tab_content = wibox.widget({
{
awful.widget.clienticon(c),
top = dpi(6),
left = dpi(15),
bottom = dpi(6),
widget = wibox.container.margin,
},
text_temp,
nill,
expand = "none",
layout = wibox.layout.align.horizontal,
})
local close = create_title_button(c, close_color, bg_normal)
close:connect_signal("button::press", function()
c:kill()
end)
local floating = create_title_button(c, float_color, bg_normal)
floating:connect_signal("button::press", function()
c.floating = not c.floating
end)
local min = create_title_button(c, min_color, bg_normal)
min:connect_signal("button::press", function()
c.minimized = true
end)
if focused_bool then
tab_content = wibox.widget({
{
awful.widget.clienticon(c),
top = dpi(10),
left = dpi(15),
bottom = dpi(10),
widget = wibox.container.margin,
},
text_temp,
{
{ min, floating, close, layout = wibox.layout.fixed.horizontal },
top = dpi(10),
right = dpi(10),
bottom = dpi(10),
widget = wibox.container.margin,
},
expand = "none",
layout = wibox.layout.align.horizontal,
})
end
local main_content = nil
local left_shape = nil
local right_shape = nil
if position == "top" then
main_content = wibox.widget({
{
tab_content,
bg = bg_temp,
shape = helpers.shape.prrect(
border_radius,
true,
true,
false,
false
),
widget = wibox.container.background,
},
top = dpi(8),
widget = wibox.container.margin,
})
left_shape = helpers.shape.prrect(
border_radius,
false,
false,
true,
false
)
right_shape = helpers.shape.prrect(
border_radius,
false,
false,
false,
true
)
else
main_content = wibox.widget({
{
tab_content,
bg = bg_temp,
shape = helpers.shape.prrect(
border_radius,
false,
false,
true,
true
),
widget = wibox.container.background,
},
bottom = dpi(8),
widget = wibox.container.margin,
})
left_shape = helpers.shape.prrect(
border_radius,
false,
true,
false,
false
)
right_shape = helpers.shape.prrect(
border_radius,
true,
false,
false,
false
)
end
local wid_temp = wibox.widget({
buttons = buttons,
{
{
{
wibox.widget.textbox(),
bg = bg_normal,
shape = left_shape,
widget = wibox.container.background,
},
bg = bg_temp,
shape = gears.rectangle,
widget = wibox.container.background,
},
width = border_radius + (border_radius / 2),
height = size,
strategy = "exact",
layout = wibox.layout.constraint,
},
main_content,
{
{
{
wibox.widget.textbox(),
bg = bg_normal,
shape = right_shape,
widget = wibox.container.background,
},
bg = bg_temp,
shape = gears.rectangle,
widget = wibox.container.background,
},
width = border_radius + (border_radius / 2),
height = size,
strategy = "exact",
layout = wibox.layout.constraint,
},
layout = wibox.layout.align.horizontal,
})
return wid_temp
end
return {
layout = wibox.layout.flex.horizontal,
create = create,
position = position,
size = size,
bg_normal = bg_normal,
bg_focus = bg_focus,
}

View file

@ -1,81 +0,0 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local gcolor = require("gears.color")
local beautiful = require("beautiful")
local bg_normal = beautiful.tabbar_bg_normal or beautiful.bg_normal or "#ffffff"
local fg_normal = beautiful.tabbar_fg_normal or beautiful.fg_normal or "#000000"
local bg_focus = beautiful.tabbar_bg_focus or beautiful.bg_focus or "#000000"
local fg_focus = beautiful.tabbar_fg_focus or beautiful.fg_focus or "#ffffff"
local bg_focus_inactive = beautiful.tabbar_bg_focus_inactive or bg_focus
local fg_focus_inactive = beautiful.tabbar_fg_focus_inactive or fg_focus
local bg_normal_inactive = beautiful.tabbar_bg_normal_inactive or bg_normal
local fg_normal_inactive = beautiful.tabbar_fg_normal_inactive or fg_normal
local font = beautiful.tabbar_font or beautiful.font or "Hack 15"
local size = beautiful.tabbar_size or 20
local position = beautiful.tabbar_position or "top"
local function create(c, focused_bool, buttons, inactive_bool)
local bg_temp = inactive_bool and bg_normal_inactive or bg_normal
local fg_temp = inactive_bool and fg_normal_inactive or fg_normal
if focused_bool then
bg_temp = inactive_bool and bg_focus_inactive or bg_focus
fg_temp = inactive_bool and fg_focus_inactive or fg_focus
end
local wid_temp = wibox.widget({
{
{ -- Left
wibox.widget.base.make_widget(
awful.titlebar.widget.iconwidget(c)
),
buttons = buttons,
layout = wibox.layout.fixed.horizontal,
},
{ -- Title
wibox.widget.base.make_widget(
awful.titlebar.widget.titlewidget(c)
),
buttons = buttons,
widget = wibox.container.place,
},
{ -- Right
focused_bool and wibox.widget.base.make_widget(
awful.titlebar.widget.floatingbutton(c)
) or nil,
focused_bool and wibox.widget.base.make_widget(
awful.titlebar.widget.stickybutton(c)
) or nil,
focused_bool and wibox.widget.base.make_widget(
awful.titlebar.widget.ontopbutton(c)
) or nil,
focused_bool and wibox.widget.base.make_widget(
awful.titlebar.widget.maximizedbutton(c)
) or nil,
focused_bool and wibox.widget.base.make_widget(
awful.titlebar.widget.minimizebutton(c)
) or nil,
focused_bool and wibox.widget.base.make_widget(
awful.titlebar.widget.closebutton(c)
) or nil,
layout = wibox.layout.fixed.horizontal,
},
layout = wibox.layout.align.horizontal,
},
bg = bg_temp,
fg = fg_temp,
widget = wibox.container.background,
})
return wid_temp
end
return {
layout = wibox.layout.flex.horizontal,
create = create,
position = position,
size = size,
bg_normal = bg_normal,
bg_focus = bg_focus,
}

View file

@ -1,51 +0,0 @@
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local dpi = require("beautiful.xresources").apply_dpi
local function tabobj_support(self, c, index, clients)
-- Self is the background widget in this context
if not c.bling_tabbed and #c.bling_tabbed.clients > 1 then
return
end
local group = c.bling_tabbed
-- TODO: Allow customization here
local layout_v = wibox.widget {
vertical_spacing = dpi(2),
horizontal_spacing = dpi(2),
layout = wibox.layout.grid.horizontal,
forced_num_rows = 2,
forced_num_cols = 2,
homogeneous = true
}
local wrapper = wibox.widget({
layout_v,
id = "click_role",
widget = wibox.container.margin,
margins = dpi(5),
})
-- To get the ball rolling.
for idx, c in ipairs(group.clients) do
if not (c and c.icon) then goto skip end
-- Add to the last layout
layout_v:add(wibox.widget {
{
widget = awful.widget.clienticon,
client = c
},
widget = wibox.container.constraint,
width = dpi(24),
height = dpi(24)
})
::skip::
end
self.widget = wrapper
end
return tabobj_support

View file

@ -1,9 +0,0 @@
return {
titlebar_indicator = require(
tostring(...):match(".*bling")
.. ".widget.tabbed_misc.titlebar_indicator"
),
custom_tasklist = require(
tostring(...):match(".*bling") .. ".widget.tabbed_misc.custom_tasklist"
),
}

View file

@ -1,133 +0,0 @@
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
local beautiful = require("beautiful")
local dpi = require("beautiful.xresources").apply_dpi
local tabbed_module = require(
tostring(...):match(".*bling") .. ".module.tabbed"
)
-- Just check if a table contains a value.
local function tbl_contains(tbl, item)
for _, v in ipairs(tbl) do
if v == item then
return true
end
end
return false
end
-- Needs to be run, every time a new titlbear is created
return function(c, opts)
-- Args & Fallback -- Widget templates are in their original loactions
opts = gears.table.crush({
layout_spacing = dpi(4),
icon_size = dpi(20),
icon_margin = dpi(4),
bg_color_focus = "#ff0000",
bg_color = "#00000000",
fg_color = "#fafafa",
fg_color_focus = "#e0e0e0",
icon_shape = function(cr, w, h)
gears.shape.rounded_rect(cr, w, h, 0)
end,
layout = wibox.layout.fixed.horizontal,
}, gears.table.join(
opts,
beautiful.bling_tabbed_misc_titlebar_indicator
))
-- Container to store icons
local tabbed_icons = wibox.widget({
layout = opts.layout,
spacing = opts.layout_spacing,
})
awesome.connect_signal("bling::tabbed::client_removed", function(_, removed_c)
-- Remove from list
for idx, icon in ipairs(tabbed_icons.children) do
if icon._client == removed_c then
tabbed_icons:remove(idx)
end
end
-- Empty list
if removed_c == c then
tabbed_icons:reset()
end
end)
local function recreate(group)
if tbl_contains(group.clients, c) then
tabbed_icons:reset()
local focused = group.clients[group.focused_idx]
-- Autohide?
if #group.clients == 1 then
return
end
for idx, client in ipairs(group.clients) do
local widget = wibox.widget(
opts.widget_template or {
{
{
{
id = "icon_role",
forced_width = opts.icon_size,
forced_height = opts.icon_size,
widget = awful.widget.clienticon,
},
margins = opts.icon_margin,
widget = wibox.container.margin,
},
shape = opts.icon_shape,
id = "bg_role",
widget = wibox.container.background,
},
halign = "center",
valign = "center",
widget = wibox.container.place,
})
widget._client = client
-- No creation call back since this would be called on creation & every time the widget updated.
if opts.widget_template and opts.widget_template.update_callback then
opts.widget_template.update_callback(widget, client, group)
end
-- Add icons & etc
for _, w in ipairs(widget:get_children_by_id("icon_role")) do
-- TODO: Allow fallback icon?
w.image = client.icon
w.client = client
end
for _, w in ipairs(widget:get_children_by_id("bg_role")) do
w:add_button(awful.button({}, 1, function()
tabbed_module.switch_to(group, idx)
end))
if client == focused then
w.bg = opts.bg_color_focus
w.fg = opts.fg_color_focus
else
w.bg = opts.bg_color
w.fg = opts.fg_color
end
end
for _, w in ipairs(widget:get_children_by_id("text_role")) do
w.text = client.name
end
tabbed_icons:add(widget)
end
end
end
awesome.connect_signal("bling::tabbed::client_added", recreate)
awesome.connect_signal("bling::tabbed::changed_focus", recreate)
return tabbed_icons
end

View file

@ -1,246 +0,0 @@
--
-- Provides:
-- bling::tag_preview::update -- first line is the signal
-- t (tag) -- indented lines are function parameters
-- bling::tag_preview::visibility
-- s (screen)
-- v (boolean)
--
local awful = require("awful")
local wibox = require("wibox")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local gears = require("gears")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
local cairo = require("lgi").cairo
local function draw_widget(
t,
tag_preview_image,
scale,
screen_radius,
client_radius,
client_opacity,
client_bg,
client_border_color,
client_border_width,
widget_bg,
widget_border_color,
widget_border_width,
geo,
margin,
background_image
)
local client_list = wibox.layout.manual()
client_list.forced_height = geo.height
client_list.forced_width = geo.width
local tag_screen = t.screen
for i, c in ipairs(t:clients()) do
if not c.hidden and not c.minimized then
local img_box = wibox.widget ({
resize = true,
forced_height = 100 * scale,
forced_width = 100 * scale,
widget = wibox.widget.imagebox,
})
-- If fails to set image, fallback to a awesome icon
if not pcall(function() img_box.image = gears.surface.load(c.icon) end) then
img_box.image = beautiful.theme_assets.awesome_icon (24, "#222222", "#fafafa")
end
if tag_preview_image then
if c.prev_content or t.selected then
local content
if t.selected then
content = gears.surface(c.content)
else
content = gears.surface(c.prev_content)
end
local cr = cairo.Context(content)
local x, y, w, h = cr:clip_extents()
local img = cairo.ImageSurface.create(
cairo.Format.ARGB32,
w - x,
h - y
)
cr = cairo.Context(img)
cr:set_source_surface(content, 0, 0)
cr.operator = cairo.Operator.SOURCE
cr:paint()
img_box = wibox.widget({
image = gears.surface.load(img),
resize = true,
opacity = client_opacity,
forced_height = math.floor(c.height * scale),
forced_width = math.floor(c.width * scale),
widget = wibox.widget.imagebox,
})
end
end
local client_box = wibox.widget({
{
nil,
{
nil,
img_box,
nil,
expand = "outside",
layout = wibox.layout.align.horizontal,
},
nil,
expand = "outside",
widget = wibox.layout.align.vertical,
},
forced_height = math.floor(c.height * scale),
forced_width = math.floor(c.width * scale),
bg = client_bg,
shape_border_color = client_border_color,
shape_border_width = client_border_width,
shape = helpers.shape.rrect(client_radius),
widget = wibox.container.background,
})
client_box.point = {
x = math.floor((c.x - geo.x) * scale),
y = math.floor((c.y - geo.y) * scale),
}
client_list:add(client_box)
end
end
return wibox.widget {
{
background_image,
{
{
{
{
client_list,
forced_height = geo.height,
forced_width = geo.width,
widget = wibox.container.place,
},
layout = wibox.layout.align.horizontal,
},
layout = wibox.layout.align.vertical,
},
margins = margin,
widget = wibox.container.margin,
},
layout = wibox.layout.stack
},
bg = widget_bg,
shape_border_width = widget_border_width,
shape_border_color = widget_border_color,
shape = helpers.shape.rrect(screen_radius),
widget = wibox.container.background,
}
end
local enable = function(opts)
local opts = opts or {}
local tag_preview_image = opts.show_client_content or false
local widget_x = opts.x or dpi(20)
local widget_y = opts.y or dpi(20)
local scale = opts.scale or 0.2
local work_area = opts.honor_workarea or false
local padding = opts.honor_padding or false
local placement_fn = opts.placement_fn or nil
local background_image = opts.background_widget or nil
local margin = beautiful.tag_preview_widget_margin or dpi(0)
local screen_radius = beautiful.tag_preview_widget_border_radius or dpi(0)
local client_radius = beautiful.tag_preview_client_border_radius or dpi(0)
local client_opacity = beautiful.tag_preview_client_opacity or 0.5
local client_bg = beautiful.tag_preview_client_bg or "#000000"
local client_border_color = beautiful.tag_preview_client_border_color
or "#ffffff"
local client_border_width = beautiful.tag_preview_client_border_width
or dpi(3)
local widget_bg = beautiful.tag_preview_widget_bg or "#000000"
local widget_border_color = beautiful.tag_preview_widget_border_color
or "#ffffff"
local widget_border_width = beautiful.tag_preview_widget_border_width
or dpi(3)
local tag_preview_box = awful.popup({
type = "dropdown_menu",
visible = false,
ontop = true,
placement = placement_fn,
widget = wibox.container.background,
input_passthrough = true,
bg = "#00000000",
})
tag.connect_signal("property::selected", function(t)
-- Awesome switches up tags on startup really fast it seems, probably depends on what rules you have set
-- which can cause the c.content to not show the correct image
gears.timer
{
timeout = 0.1,
call_now = false,
autostart = true,
single_shot = true,
callback = function()
if t.selected == true then
for _, c in ipairs(t:clients()) do
c.prev_content = gears.surface.duplicate_surface(c.content)
end
end
end
}
end)
awesome.connect_signal("bling::tag_preview::update", function(t)
local geo = t.screen:get_bounding_geometry({
honor_padding = padding,
honor_workarea = work_area,
})
tag_preview_box.maximum_width = scale * geo.width + margin * 2
tag_preview_box.maximum_height = scale * geo.height + margin * 2
tag_preview_box.widget = draw_widget(
t,
tag_preview_image,
scale,
screen_radius,
client_radius,
client_opacity,
client_bg,
client_border_color,
client_border_width,
widget_bg,
widget_border_color,
widget_border_width,
geo,
margin,
background_image
)
end)
awesome.connect_signal("bling::tag_preview::visibility", function(s, v)
if not placement_fn then
tag_preview_box.x = s.geometry.x + widget_x
tag_preview_box.y = s.geometry.y + widget_y
end
if v == false then
tag_preview_box.widget = nil
collectgarbage("collect")
end
tag_preview_box.visible = v
end)
end
return {enable = enable, draw_widget = draw_widget}

View file

@ -1,199 +0,0 @@
--
-- Provides:
-- bling::task_preview::visibility
-- s (screen)
-- v (boolean)
-- c (client)
--
local awful = require("awful")
local wibox = require("wibox")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local gears = require("gears")
local beautiful = require("beautiful")
local dpi = beautiful.xresources.apply_dpi
local cairo = require("lgi").cairo
-- TODO: rename structure to something better?
local function draw_widget(
c,
widget_template,
screen_radius,
widget_bg,
widget_border_color,
widget_border_width,
margin,
widget_width,
widget_height
)
if not pcall(function()
return type(c.content)
end) then
return
end
local content = nil
if c.active then
content = gears.surface(c.content)
elseif c.prev_content then
content = gears.surface(c.prev_content)
end
local img = nil
if content ~= nil then
local cr = cairo.Context(content)
local x, y, w, h = cr:clip_extents()
img = cairo.ImageSurface.create(cairo.Format.ARGB32, w - x, h - y)
cr = cairo.Context(img)
cr:set_source_surface(content, 0, 0)
cr.operator = cairo.Operator.SOURCE
cr:paint()
end
local widget = wibox.widget({
(widget_template or {
{
{
{
{
id = "icon_role",
resize = true,
forced_height = dpi(20),
forced_width = dpi(20),
widget = wibox.widget.imagebox,
},
{
{
id = "name_role",
align = "center",
widget = wibox.widget.textbox,
},
left = dpi(4),
right = dpi(4),
widget = wibox.container.margin,
},
layout = wibox.layout.align.horizontal,
},
{
{
{
id = "image_role",
resize = true,
clip_shape = helpers.shape.rrect(screen_radius),
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
widget = wibox.container.place,
},
top = margin * 0.25,
widget = wibox.container.margin,
},
fill_space = true,
layout = wibox.layout.fixed.vertical,
},
margins = margin,
widget = wibox.container.margin,
},
bg = widget_bg,
shape_border_width = widget_border_width,
shape_border_color = widget_border_color,
shape = helpers.shape.rrect(screen_radius),
widget = wibox.container.background,
}),
width = widget_width,
height = widget_height,
widget = wibox.container.constraint,
})
-- TODO: have something like a create callback here?
for _, w in ipairs(widget:get_children_by_id("image_role")) do
w.image = img -- TODO: copy it with gears.surface.xxx or something
end
for _, w in ipairs(widget:get_children_by_id("name_role")) do
w.text = c.name
end
for _, w in ipairs(widget:get_children_by_id("icon_role")) do
w.image = c.icon -- TODO: detect clienticon
end
return widget
end
local enable = function(opts)
local opts = opts or {}
local widget_x = opts.x or dpi(20)
local widget_y = opts.y or dpi(20)
local widget_height = opts.height or dpi(200)
local widget_width = opts.width or dpi(200)
local placement_fn = opts.placement_fn or nil
local margin = beautiful.task_preview_widget_margin or dpi(0)
local screen_radius = beautiful.task_preview_widget_border_radius or dpi(0)
local widget_bg = beautiful.task_preview_widget_bg or "#000000"
local widget_border_color = beautiful.task_preview_widget_border_color
or "#ffffff"
local widget_border_width = beautiful.task_preview_widget_border_width
or dpi(3)
local task_preview_box = awful.popup({
type = "dropdown_menu",
visible = false,
ontop = true,
placement = placement_fn,
widget = wibox.container.background, -- A dummy widget to make awful.popup not scream
input_passthrough = true,
bg = "#00000000",
})
tag.connect_signal("property::selected", function(t)
-- Awesome switches up tags on startup really fast it seems, probably depends on what rules you have set
-- which can cause the c.content to not show the correct image
gears.timer
{
timeout = 0.1,
call_now = false,
autostart = true,
single_shot = true,
callback = function()
if t.selected == true then
for _, c in ipairs(t:clients()) do
c.prev_content = gears.surface.duplicate_surface(c.content)
end
end
end
}
end)
awesome.connect_signal("bling::task_preview::visibility", function(s, v, c)
if v then
-- Update task preview contents
task_preview_box.widget = draw_widget(
c,
opts.structure,
screen_radius,
widget_bg,
widget_border_color,
widget_border_width,
margin,
widget_width,
widget_height
)
else
task_preview_box.widget = nil
collectgarbage("collect")
end
if not placement_fn then
task_preview_box.x = s.geometry.x + widget_x
task_preview_box.y = s.geometry.y + widget_y
end
task_preview_box.visible = v
end)
end
return { enable = enable, draw_widget = draw_widget }

View file

@ -1,461 +0,0 @@
local cairo = require("lgi").cairo
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
local beautiful = require("beautiful")
local helpers = require(tostring(...):match(".*bling") .. ".helpers")
local dpi = beautiful.xresources.apply_dpi
local window_switcher_first_client -- The client that was focused when the window_switcher was activated
local window_switcher_minimized_clients = {} -- The clients that were minimized when the window switcher was activated
local window_switcher_grabber
local get_num_clients = function()
local minimized_clients_in_tag = 0
local matcher = function(c)
return awful.rules.match(
c,
{
minimized = true,
skip_taskbar = false,
hidden = false,
first_tag = awful.screen.focused().selected_tag,
}
)
end
for c in awful.client.iterate(matcher) do
minimized_clients_in_tag = minimized_clients_in_tag + 1
end
return minimized_clients_in_tag + #awful.screen.focused().clients
end
local window_switcher_hide = function(window_switcher_box)
-- Add currently focused client to history
if client.focus then
local window_switcher_last_client = client.focus
awful.client.focus.history.add(window_switcher_last_client)
-- Raise client that was focused originally
-- Then raise last focused client
if
window_switcher_first_client and window_switcher_first_client.valid
then
window_switcher_first_client:raise()
window_switcher_last_client:raise()
end
end
-- Minimize originally minimized clients
local s = awful.screen.focused()
for _, c in pairs(window_switcher_minimized_clients) do
if c and c.valid and not (client.focus and client.focus == c) then
c.minimized = true
end
end
-- Reset helper table
window_switcher_minimized_clients = {}
-- Resume recording focus history
awful.client.focus.history.enable_tracking()
-- Stop and hide window_switcher
awful.keygrabber.stop(window_switcher_grabber)
window_switcher_box.visible = false
window_switcher_box.widget = nil
collectgarbage("collect")
end
local function draw_widget(
type,
background,
border_width,
border_radius,
border_color,
clients_spacing,
client_icon_horizontal_spacing,
client_width,
client_height,
client_margins,
thumbnail_margins,
thumbnail_scale,
name_margins,
name_valign,
name_forced_width,
name_font,
name_normal_color,
name_focus_color,
icon_valign,
icon_width,
mouse_keys,
filterClients
)
filterClients = filterClients or awful.widget.tasklist.filter.currenttags
local tasklist_widget = type == "thumbnail"
and awful.widget.tasklist({
screen = awful.screen.focused(),
filter = filterClients,
buttons = mouse_keys,
style = {
font = name_font,
fg_normal = name_normal_color,
fg_focus = name_focus_color,
},
layout = {
layout = wibox.layout.flex.horizontal,
spacing = clients_spacing,
},
widget_template = {
widget = wibox.container.background,
id = "bg_role",
forced_width = client_width,
forced_height = client_height,
create_callback = function(self, c, _, __)
local content = gears.surface(c.content)
local cr = cairo.Context(content)
local x, y, w, h = cr:clip_extents()
local img = cairo.ImageSurface.create(
cairo.Format.ARGB32,
w - x,
h - y
)
cr = cairo.Context(img)
cr:set_source_surface(content, 0, 0)
cr.operator = cairo.Operator.SOURCE
cr:paint()
self:get_children_by_id("thumbnail")[1].image =
gears.surface.load(
img
)
end,
{
{
{
horizontal_fit_policy = thumbnail_scale == true
and "fit"
or "auto",
vertical_fit_policy = thumbnail_scale == true
and "fit"
or "auto",
id = "thumbnail",
widget = wibox.widget.imagebox,
},
margins = thumbnail_margins,
widget = wibox.container.margin,
},
{
{
{
id = "icon_role",
widget = wibox.widget.imagebox,
},
forced_width = icon_width,
valign = icon_valign,
widget = wibox.container.place,
},
{
{
forced_width = name_forced_width,
valign = name_valign,
id = "text_role",
widget = wibox.widget.textbox,
},
margins = name_margins,
widget = wibox.container.margin,
},
spacing = client_icon_horizontal_spacing,
layout = wibox.layout.fixed.horizontal,
},
layout = wibox.layout.flex.vertical,
},
},
})
or awful.widget.tasklist({
screen = awful.screen.focused(),
filter = filterClients,
buttons = mouse_keys,
style = {
font = name_font,
fg_normal = name_normal_color,
fg_focus = name_focus_color,
},
layout = {
layout = wibox.layout.fixed.vertical,
spacing = clients_spacing,
},
widget_template = {
widget = wibox.container.background,
id = "bg_role",
forced_width = client_width,
forced_height = client_height,
{
{
{
id = "icon_role",
widget = wibox.widget.imagebox,
},
forced_width = icon_width,
valign = icon_valign,
widget = wibox.container.place,
},
{
{
forced_width = name_forced_width,
valign = name_valign,
id = "text_role",
widget = wibox.widget.textbox,
},
margins = name_margins,
widget = wibox.container.margin,
},
spacing = client_icon_horizontal_spacing,
layout = wibox.layout.fixed.horizontal,
},
},
})
return wibox.widget({
{
tasklist_widget,
margins = client_margins,
widget = wibox.container.margin,
},
shape_border_width = border_width,
shape_border_color = border_color,
bg = background,
shape = helpers.shape.rrect(border_radius),
widget = wibox.container.background,
})
end
local enable = function(opts)
local opts = opts or {}
local type = opts.type or "thumbnail"
local background = beautiful.window_switcher_widget_bg or "#000000"
local border_width = beautiful.window_switcher_widget_border_width or dpi(3)
local border_radius = beautiful.window_switcher_widget_border_radius
or dpi(0)
local border_color = beautiful.window_switcher_widget_border_color
or "#ffffff"
local clients_spacing = beautiful.window_switcher_clients_spacing or dpi(20)
local client_icon_horizontal_spacing = beautiful.window_switcher_client_icon_horizontal_spacing
or dpi(5)
local client_width = beautiful.window_switcher_client_width
or dpi(type == "thumbnail" and 150 or 500)
local client_height = beautiful.window_switcher_client_height
or dpi(type == "thumbnail" and 250 or 50)
local client_margins = beautiful.window_switcher_client_margins or dpi(10)
local thumbnail_margins = beautiful.window_switcher_thumbnail_margins
or dpi(5)
local thumbnail_scale = beautiful.thumbnail_scale or false
local name_margins = beautiful.window_switcher_name_margins or dpi(10)
local name_valign = beautiful.window_switcher_name_valign or "center"
local name_forced_width = beautiful.window_switcher_name_forced_width
or dpi(type == "thumbnail" and 200 or 550)
local name_font = beautiful.window_switcher_name_font or beautiful.font
local name_normal_color = beautiful.window_switcher_name_normal_color
or "#FFFFFF"
local name_focus_color = beautiful.window_switcher_name_focus_color
or "#FF0000"
local icon_valign = beautiful.window_switcher_icon_valign or "center"
local icon_width = beautiful.window_switcher_icon_width or dpi(40)
local hide_window_switcher_key = opts.hide_window_switcher_key or "Escape"
local select_client_key = opts.select_client_key or 1
local minimize_key = opts.minimize_key or "n"
local unminimize_key = opts.unminimize_key or "N"
local kill_client_key = opts.kill_client_key or "q"
local cycle_key = opts.cycle_key or "Tab"
local previous_key = opts.previous_key or "Left"
local next_key = opts.next_key or "Right"
local vim_previous_key = opts.vim_previous_key or "h"
local vim_next_key = opts.vim_next_key or "l"
local scroll_previous_key = opts.scroll_previous_key or 4
local scroll_next_key = opts.scroll_next_key or 5
local cycleClientsByIdx = opts.cycleClientsByIdx or awful.client.focus.byidx
local filterClients = opts.filterClients or awful.widget.tasklist.filter.currenttags
local window_switcher_box = awful.popup({
bg = "#00000000",
visible = false,
ontop = true,
placement = awful.placement.centered,
screen = awful.screen.focused(),
widget = wibox.container.background, -- A dummy widget to make awful.popup not scream
widget = {
{
draw_widget(),
margins = client_margins,
widget = wibox.container.margin,
},
shape_border_width = border_width,
shape_border_color = border_color,
bg = background,
shape = helpers.shape.rrect(border_radius),
widget = wibox.container.background,
},
})
local mouse_keys = gears.table.join(
awful.button({
modifiers = { "Any" },
button = select_client_key,
on_press = function(c)
client.focus = c
end,
}),
awful.button({
modifiers = { "Any" },
button = scroll_previous_key,
on_press = function()
cycleClientsByIdx(-1)
end,
}),
awful.button({
modifiers = { "Any" },
button = scroll_next_key,
on_press = function()
cycleClientsByIdx(1)
end,
})
)
local keyboard_keys = {
[hide_window_switcher_key] = function()
window_switcher_hide(window_switcher_box)
end,
[minimize_key] = function()
if client.focus then
client.focus.minimized = true
end
end,
[unminimize_key] = function()
if awful.client.restore() then
client.focus = awful.client.restore()
end
end,
[kill_client_key] = function()
if client.focus then
client.focus:kill()
end
end,
[cycle_key] = function()
cycleClientsByIdx(1)
end,
[previous_key] = function()
cycleClientsByIdx(1)
end,
[next_key] = function()
cycleClientsByIdx(-1)
end,
[vim_previous_key] = function()
cycleClientsByIdx(1)
end,
[vim_next_key] = function()
cycleClientsByIdx(-1)
end,
}
window_switcher_box:connect_signal("property::width", function()
if window_switcher_box.visible and get_num_clients() == 0 then
window_switcher_hide(window_switcher_box)
end
end)
window_switcher_box:connect_signal("property::height", function()
if window_switcher_box.visible and get_num_clients() == 0 then
window_switcher_hide(window_switcher_box)
end
end)
awesome.connect_signal("bling::window_switcher::turn_on", function()
local number_of_clients = get_num_clients()
if number_of_clients == 0 then
return
end
-- Store client that is focused in a variable
window_switcher_first_client = client.focus
-- Stop recording focus history
awful.client.focus.history.disable_tracking()
-- Go to previously focused client (in the tag)
awful.client.focus.history.previous()
-- Track minimized clients
-- Unminimize them
-- Lower them so that they are always below other
-- originally unminimized windows
local clients = awful.screen.focused().selected_tag:clients()
for _, c in pairs(clients) do
if c.minimized then
table.insert(window_switcher_minimized_clients, c)
c.minimized = false
c:lower()
end
end
-- Start the keygrabber
window_switcher_grabber = awful.keygrabber.run(function(_, key, event)
if event == "release" then
-- Hide if the modifier was released
-- We try to match Super or Alt or Control since we do not know which keybind is
-- used to activate the window switcher (the keybind is set by the user in keys.lua)
if
key:match("Super")
or key:match("Alt")
or key:match("Control")
then
window_switcher_hide(window_switcher_box)
end
-- Do nothing
return
end
-- Run function attached to key, if it exists
if keyboard_keys[key] then
keyboard_keys[key]()
end
end)
window_switcher_box.widget = draw_widget(
type,
background,
border_width,
border_radius,
border_color,
clients_spacing,
client_icon_horizontal_spacing,
client_width,
client_height,
client_margins,
thumbnail_margins,
thumbnail_scale,
name_margins,
name_valign,
name_forced_width,
name_font,
name_normal_color,
name_focus_color,
icon_valign,
icon_width,
mouse_keys,
filterClients
)
window_switcher_box.screen = awful.screen.focused()
window_switcher_box.visible = true
end)
end
return { enable = enable }

View file

@ -1,388 +0,0 @@
--
-- json.lua
--
-- Copyright (c) 2020 rxi
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
-- the Software without restriction, including without limitation the rights to
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-- of the Software, and to permit persons to whom the Software is furnished to do
-- so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--
local json = { _version = "0.1.2" }
-------------------------------------------------------------------------------
-- Encode
-------------------------------------------------------------------------------
local encode
local escape_char_map = {
[ "\\" ] = "\\",
[ "\"" ] = "\"",
[ "\b" ] = "b",
[ "\f" ] = "f",
[ "\n" ] = "n",
[ "\r" ] = "r",
[ "\t" ] = "t",
}
local escape_char_map_inv = { [ "/" ] = "/" }
for k, v in pairs(escape_char_map) do
escape_char_map_inv[v] = k
end
local function escape_char(c)
return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte()))
end
local function encode_nil(val)
return "null"
end
local function encode_table(val, stack)
local res = {}
stack = stack or {}
-- Circular reference?
if stack[val] then error("circular reference") end
stack[val] = true
if rawget(val, 1) ~= nil or next(val) == nil then
-- Treat as array -- check keys are valid and it is not sparse
local n = 0
for k in pairs(val) do
if type(k) ~= "number" then
error("invalid table: mixed or invalid key types")
end
n = n + 1
end
if n ~= #val then
error("invalid table: sparse array")
end
-- Encode
for i, v in ipairs(val) do
table.insert(res, encode(v, stack))
end
stack[val] = nil
return "[" .. table.concat(res, ",") .. "]"
else
-- Treat as an object
for k, v in pairs(val) do
if type(k) ~= "string" then
error("invalid table: mixed or invalid key types")
end
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
end
stack[val] = nil
return "{" .. table.concat(res, ",") .. "}"
end
end
local function encode_string(val)
return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
end
local function encode_number(val)
-- Check for NaN, -inf and inf
if val ~= val or val <= -math.huge or val >= math.huge then
error("unexpected number value '" .. tostring(val) .. "'")
end
return string.format("%.14g", val)
end
local type_func_map = {
[ "nil" ] = encode_nil,
[ "table" ] = encode_table,
[ "string" ] = encode_string,
[ "number" ] = encode_number,
[ "boolean" ] = tostring,
}
encode = function(val, stack)
local t = type(val)
local f = type_func_map[t]
if f then
return f(val, stack)
end
error("unexpected type '" .. t .. "'")
end
function json.encode(val)
return ( encode(val) )
end
-------------------------------------------------------------------------------
-- Decode
-------------------------------------------------------------------------------
local parse
local function create_set(...)
local res = {}
for i = 1, select("#", ...) do
res[ select(i, ...) ] = true
end
return res
end
local space_chars = create_set(" ", "\t", "\r", "\n")
local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
local literals = create_set("true", "false", "null")
local literal_map = {
[ "true" ] = true,
[ "false" ] = false,
[ "null" ] = nil,
}
local function next_char(str, idx, set, negate)
for i = idx, #str do
if set[str:sub(i, i)] ~= negate then
return i
end
end
return #str + 1
end
local function decode_error(str, idx, msg)
local line_count = 1
local col_count = 1
for i = 1, idx - 1 do
col_count = col_count + 1
if str:sub(i, i) == "\n" then
line_count = line_count + 1
col_count = 1
end
end
error( string.format("%s at line %d col %d", msg, line_count, col_count) )
end
local function codepoint_to_utf8(n)
-- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
local f = math.floor
if n <= 0x7f then
return string.char(n)
elseif n <= 0x7ff then
return string.char(f(n / 64) + 192, n % 64 + 128)
elseif n <= 0xffff then
return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
elseif n <= 0x10ffff then
return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
f(n % 4096 / 64) + 128, n % 64 + 128)
end
error( string.format("invalid unicode codepoint '%x'", n) )
end
local function parse_unicode_escape(s)
local n1 = tonumber( s:sub(1, 4), 16 )
local n2 = tonumber( s:sub(7, 10), 16 )
-- Surrogate pair?
if n2 then
return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
else
return codepoint_to_utf8(n1)
end
end
local function parse_string(str, i)
local res = ""
local j = i + 1
local k = j
while j <= #str do
local x = str:byte(j)
if x < 32 then
decode_error(str, j, "control character in string")
elseif x == 92 then -- `\`: Escape
res = res .. str:sub(k, j - 1)
j = j + 1
local c = str:sub(j, j)
if c == "u" then
local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1)
or str:match("^%x%x%x%x", j + 1)
or decode_error(str, j - 1, "invalid unicode escape in string")
res = res .. parse_unicode_escape(hex)
j = j + #hex
else
if not escape_chars[c] then
decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string")
end
res = res .. escape_char_map_inv[c]
end
k = j + 1
elseif x == 34 then -- `"`: End of string
res = res .. str:sub(k, j - 1)
return res, j + 1
end
j = j + 1
end
decode_error(str, i, "expected closing quote for string")
end
local function parse_number(str, i)
local x = next_char(str, i, delim_chars)
local s = str:sub(i, x - 1)
local n = tonumber(s)
if not n then
decode_error(str, i, "invalid number '" .. s .. "'")
end
return n, x
end
local function parse_literal(str, i)
local x = next_char(str, i, delim_chars)
local word = str:sub(i, x - 1)
if not literals[word] then
decode_error(str, i, "invalid literal '" .. word .. "'")
end
return literal_map[word], x
end
local function parse_array(str, i)
local res = {}
local n = 1
i = i + 1
while 1 do
local x
i = next_char(str, i, space_chars, true)
-- Empty / end of array?
if str:sub(i, i) == "]" then
i = i + 1
break
end
-- Read token
x, i = parse(str, i)
res[n] = x
n = n + 1
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "]" then break end
if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
end
return res, i
end
local function parse_object(str, i)
local res = {}
i = i + 1
while 1 do
local key, val
i = next_char(str, i, space_chars, true)
-- Empty / end of object?
if str:sub(i, i) == "}" then
i = i + 1
break
end
-- Read key
if str:sub(i, i) ~= '"' then
decode_error(str, i, "expected string for key")
end
key, i = parse(str, i)
-- Read ':' delimiter
i = next_char(str, i, space_chars, true)
if str:sub(i, i) ~= ":" then
decode_error(str, i, "expected ':' after key")
end
i = next_char(str, i + 1, space_chars, true)
-- Read value
val, i = parse(str, i)
-- Set
res[key] = val
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "}" then break end
if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
end
return res, i
end
local char_func_map = {
[ '"' ] = parse_string,
[ "0" ] = parse_number,
[ "1" ] = parse_number,
[ "2" ] = parse_number,
[ "3" ] = parse_number,
[ "4" ] = parse_number,
[ "5" ] = parse_number,
[ "6" ] = parse_number,
[ "7" ] = parse_number,
[ "8" ] = parse_number,
[ "9" ] = parse_number,
[ "-" ] = parse_number,
[ "t" ] = parse_literal,
[ "f" ] = parse_literal,
[ "n" ] = parse_literal,
[ "[" ] = parse_array,
[ "{" ] = parse_object,
}
parse = function(str, idx)
local chr = str:sub(idx, idx)
local f = char_func_map[chr]
if f then
return f(str, idx)
end
decode_error(str, idx, "unexpected character '" .. chr .. "'")
end
function json.decode(str)
if type(str) ~= "string" then
error("expected argument of type string, got " .. type(str))
end
local res, idx = parse(str, next_char(str, 1, space_chars, true))
idx = next_char(str, idx, space_chars, true)
if idx <= #str then
decode_error(str, idx, "trailing garbage")
end
return res
end
return json

View file

@ -1,11 +0,0 @@
root = true
[*.lua]
charset = utf-8
intent_style = tab
indent_size = 4
trim_trailing_whitespace = true
max_line_length = 120
[*.md]
trim_trailing_whitespace = false

View file

@ -1 +0,0 @@
tags

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 andOrlando
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,415 +0,0 @@
# rubato
- [Background and explanation](#background)
- [How to actually use it](#usage)
- [But why though?](#why)
- [Arguments and Methods](#arguments-methods)
- [Custom Easing Functions](#easing)
- [Installation](#install)
- [Why the name?](#name)
- [Todo](#todo)
Basically like [awestore](https://github.com/K4rakara/awestore) but not really.
Join the cool curve crew
<!-- look colleges might see this and think its distasteful so I'm commenting it out for the moment
<img src="https://cdn.discordapp.com/attachments/702548961780826212/879022533314216007/download.jpeg" height=160>-->
<h1 id="background">Background and Explanation</h1>
The general premise of this is that I don't understand how awestore works. That and I really wanted to be able to have an interpolator that didn't have a set time. That being said, I haven't made an interpolator that doesn't have a set time yet, so I just have this instead. It has a similar function to awestore but the method in which you actually go about doing the easing is very different.
When creating an animation, the goal is to make it as smooth as humanly possible, but I was finding that with conventional methods, should the animation be interrupted with another call for animation, it would look jerky and inconsistent. You can see this jerkiness everywhere in websites made by professionals and it makes me very sad. I didnt want that for my desktop so I used a bit of a different method.
This jerkiness is typically caused by discontinuous velocity graphs. One moment its slowing down, and the next its way too fast. This is caused by just lazily starting the animation anew when already in the process of animating. This kind of velocity graph looks like this:
<img src="images/disconnected_graph.png" alt="Disconnected Velocity Graph" height=160/>
Whereas rubato takes into account this initial velocity and restarts animation taking it into account. In the case of one wanting to interpolate from one point to another and then back, it would look like this:
<img src="images/connected_graph.png" alt="Connected Velocity Graph" height=160/>
<sub><sup>okay maybe my graph consistancy is trash, what can I do...</sup></sub>
These are what they would look like with forwards-and-back animations. A forwards-than-forwards animation would look more like this, just for reference:
<img src="images/forwards_forwards_graph.png" alt="Forwards ForwardsGraph" height=160/>
To ask one of you to give these graphs as inputs, however, would be really dumb. So instead we define an intro function and its duration, which in the figure above is the `y=x` portion, an outro function and its duration, which is the `y=-x` portion, and the rest is filled with constant velocity. The area under the curve for this must be equal to the position for this to end up at the correct position (antiderivative of velocity is position). If we know the area under the curve for the intro and outro functions, the only component we need to ensure that the antiderivative is equal to the position would be the height of the graph. We find that with this formula:
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}m=\frac{d %2B ib(F_i(1)-1)}{i(F_i(1)-1) %2B o(F_o(1)-1) %2B t}" height=50>
where `m` is the height of the plateau, `i` is intro duration, `F_i` is the antiderivative of the intro easing function, `o` is outro duration, `F_o` is the antiderivative of the outro easing function, `d` is the total distance needed to be traveled, `b` is the initial slope, and `t` is the total duration.
We then simulate the antiderivative by adding `v(t)` (or the y-value at time `t` on the slope graph) to the current position 30 times per second (by default, but I recommend 60). There is some inaccuracy since its not a perfect antiderivative and theres some weirdness when going from positive slopes to negative slopes that I dont know how to intelligently fix (I have to simulate the antiderivative beforehand and multiply everything by a coefficient to prevent weird errors), but overall it results in good looking interruptions and I get a dopamine hit whenever I see it in action.
There are two main small issues that I cant/dont know how to fix mathematically:
- Its not perfectly accurate (it is perfectly accurate as `dt` goes to zero) which I dont think is possible to fix unless I stop simulating the antiderivative and actually calc out the function, which seems time inefficient
- When going from a positive m to a negative m, or in other words going backwards after going forwards in the animation, it will always undershoot by some value. I dont know what that value is, I dont know where it comes from, I dont know how to fix it except for lots and lots of time-consuming testing, but its there. To compensate for this, whenever theres a situation in which this will happen, I simulate the animation beforehand and multiply the entire animation by a corrective coefficient to make it do what I want
- Awesome is kinda slow at redrawing imaages, so 60 redraws per second is realistically probably not going to happen. If you were to, for example, set the redraws per second to 500 or some arbitrarily large value, if I did nothing to dt, it would take forever to complete an animaiton. So since I can't fix awesome, I just (by default but this is optional) limit the rate based on the time it takes for awesome to render the first frame of the animation (Thanks Kasper for pointing this out and showing me a solution).
So thats how it works. Id love any contributions anyones willing to give. I also have plans to create an interpolator without a set duration called `target` as opposed to `timed` when I have the time (or need it for my rice).
<h1 id="usage">How to actually use it</h1>
So to actually use it, just create the object, give it a couple parameters, give it some function to
execute, and then run it by updating `target`! In practice it'd look like this:
```lua
timed = rubato.timed {
duration = 1/2, --half a second
intro = 1/6, --one third of duration
override_dt = true, --better accuracy for testing
subscribed = function(pos) print(pos) end
}
--you can also achieve the same effect as the `subscribed` parameter with this:
--timed:subscribe(function(pos) print(pos) end)
--target is initially 0 (unless you set pos otherwise)
timed.target = 1
-- Here it prints out this:
-- 0
-- 0
-- 0.02
-- 0.06
-- 0.12
-- 0.2
-- 0.3
-- 0.4
-- 0.5
-- 0.6
-- 0.7
-- 0.8
-- 0.88
-- 0.94
-- 0.98
-- 1
-- 1
-- First 0 is because when you initially subscribe a function
-- it calls that function at the current position, which is 0
-- Last zero is because it'll snap to the exact position in
-- case of minor error which can come about from floating point
-- math or correcting for frameskips
--When called after it finishes printing, this would print out
--the same numbers but in reverse, sending it back from 1 to 0
timed.target = 0
```
If you're familiar with the awestore api and don't wanna use what I've got, you can use those methods
instead if you set `awestore_compat = true`. Its a drop-in replacement, so your old code should work perfectly with it. If it doesnt, please make an issue and Ill do my best to fix it. Please include the broken code so I can try it out myself.
So how do the animations actually look? Lets check out what I (at one point) use(ed) for my workspaces:
```lua
timed = rubato.timed {
intro = 0.1,
duration = 0.3
}
```
![Normal Easing](./images/trapezoid_easing.gif)
The above is very subtly eased. A somewhat more pronounced easing would look more like this:
```lua
timed = rubato.timed {
intro = 0.5,
duration = 1,
easing = rubato.quadratic --quadratic slope, not easing
}
```
![Quadratic Easing](./images/quadratic_easing.gif)
The first animations velocity graph looks like a trapezoid, while the second looks like the graph shown below. Note the lack of a plateau and longer duration which gives the more pronounced easing:
![More Quadratic Easing](./images/triangleish.png)
<h1 id="why">But why though?</h1>
Why go through all this hassle? Why not just use awestore? That's a good question and to be fair you can use whatever interpolator you so choose. That being said, rubato is solely focused on animation, has mathematically perfect interruptions and Ive been told it also looks smoother.
Furthermore, if you use rubato, you get to brag about how annoying it was to set up a monstrous derivative just to write a custom easing function, like the one shown in [Custom Easing Function](#easing)'s example. That's a benefit, not a downside, I promise.
Also maybe hopefully the code should be almost digestible kinda maybe. I tried my best to comment and documentate, but I actually have no idea how to do lua docs or anything.
Also it has a cooler name
<h1 id="arguments-methods">Arguments and Methods</h1>
**For rubato.timed**:
Arguments (in the form of a table):
- `duration`: the total duration of the animation
- `rate`: the number of times per second the timer executes. Higher rates mean smoother animations and less error.
- `prop_intro`: when `true`, `intro`, `outro` and `inter` represent proportional values; 0.5 would be half the duration. (def. `false`)
- `pos`: the initial position of the animation (def. `0`)
- `intro`: the duration of the intro
- `outro`: the duration of the outro (def. same as `intro`\*)
- inter: the duration of intermittent animations (def. same as `intro`\*)
- `easing`: the easing table (def. `interpolate.linear`)
- `easing_outro`: the outro easing table (def. as `easing`)
- `easing_inter`: the "intermittent" easing table, which defines which easing to use in the case of animation interruptions (def. same as `easing`)
- `subscribed`: a function to subscribe at initialization (def. `nil`)
- `override_simulate`: when `true`, will simulate everything instead of just when `dx` and `b` have opposite signs at the cost of having to do a little more work (and making my hard work on finding the formula for `m` worthless :slightly_frowning_face:) (def. `false`)
- `rapid_set`:
- `override_dt`: overrides the difference in time it takes to redraw the screen and just uses 1/rate no matter what. This results in slightly more accurate animations but they may take longer if awesome takes too long to redraw the screen. (def. `false`)
- `awestore_compat`: make api even *more* similar to awestore's (def. `false`)
- `log`: it would print additional logs, but there aren't any logs to print right now so it kinda just sits there (def. `false`)
- `debug`: basically just tags the timed instance. I use it in tandem with `manager.timed.override.forall`
All of these values (except awestore_compat and subscribed) are mutable and changing them will change how the animation looks. I do not suggest changing `pos`, however, unless you change the position of what's going to be animated in some other way
\*unless `outro + intro > 1`, it will instead go for the largest allowable outro time. Ex: duration = 1, intro = 0.6, then outro will default to 0.4.
Properties:
- `target`: when set, sets the target and starts the animation, otherwise returns the target
- `pause`: if true, the timer will have its animation suspedned until set to false again
- `running`: immutable, returns true if an animation is in progress
Methods are as follows:
- `timed:subscribe(func)`: subscribe a function to be ran every refresh of the animation
- `timed:unsubscribe(func)`: unsubscribe a function
- `timed:fire()`: run all subscribed functions at current position (you may provide it with arguments `pos`, `time` and `dx` manually if you wish, otherwise it'll use the values of the timed object)
- `timed:abort()`: stop the animation at the current position
Awestore compatibility functions (`awestore_compat` must be true):
- `timed:set(target_new)`: sets the position the animation should go to, effectively the same as setting target
- `timed:initial()`: returns the intiial position
- `timed:last()`: returns the target position, effectively the same as `timed.target`
Awestore compatibility properties:
- `timed.started`: subscribable table which is called when the animation starts or is interrupted
+ `timed.started:subscribe(func)`: subscribes a function
+ `timed.started:unsubscribe(func)`: unsubscribes a function
+ `timed.started:fire()`: runs all subscribed functions
- `timed.ended`: subscribable table which is called when the animation ends
+ `timed.ended:subscribe(func)`: subscribes a function
+ `timed.ended:unsubscribe(func)`: unsubscribes a function
+ `timed.ended:fire()`: runs all subscribed functions
**builtin easing functions**
- `easing.zero`: linear easing, zero slope
- `easing.linear`: linear slope, quadratic easing
- `easing.quadratic`: quadratic slope, cubic easing
- `easing.bouncy`: the bouncy thing as shown in the example
**functions for setting default values**
- (DEPRECIATED) `rubato.set_def_rate(rate)`: set default rate for all interpolators, takes an `int`. Please use instead `manager.timed.default.rate = rate`
- (DEPRECIATED) `rubato.set_override_dt(value))`: set default for override_dt for all interpolators, takes a `bool`. Please use instead `manager.timed.default.override_dt = value`
**For rubato.manager**
- `manager.timed.default`: a table containing properties of timed objects as keys and their default values as values. Updating values in this table changes those defaults. Ex: `manager.timed.default.rate = 60` sets default rate to 60 fps
- `manager.timed.override`: a table with accessors which set properties of all tables. Updating values in this table changes the properties of all tables. Ex: `manager.timed.override.is_instant = true` makes all animations instantaneous globally
- `manager.timed.override.clear()`: resets all timeds to their initial values
- `manager.timed.override.forall(func)`: run some function for all timed objects. Parameter to function is a single timed object. Ex: `manager.timed.override.forall(function(timed) print(timed) end)` prints all timeds
<h1 id="easing">Custom Easing Functions</h1>
To make a custom easing function, it's pretty easy. You just need a table with two values:
- `easing`, which is the function of the slope curve you want. So if you want quadratic easing
you'd take the derivative, which would result in linear easing. **Important:** `f(0)=0` and
`f(1)=1` must be true for it to look nice.
- `F`, which is basically just the value of the antiderivative of the easing function at `x=1`.
This is the antiderivative of the scaled function (``(0,0) (1,1) ∈ f``), however, so be wary of that.
In practice, creating your own easing would look like this:
1. Go to [easings.net](https://easings.net)
For the sake of this tutorial, we'll do both an easy easing and a complex one. The easy easing will
be the beautifully simple and quite frankly obvious quadratic. The much worse easing will be "ease
in elastic."
2. Find the necessary information
For quadratic we already know the function: `y=x^2`. I don't even need to use latex it's that easy.
For ease in elastic, we use the function given [here](https://easings.net/#easeInElastic):
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}f(x)=-2^{10 \, x - 10}\times \sin\left(-\frac{43}{6} \, \pi %2B \frac{20}{3} \, \pi x\right))">
3. Take the derivative
Quadratic: `y=2x`, easy as that.
**Important:** Look. Computers aren't the greatest at indefinite mathematics. As such, it's
possible that, like myself, you will have a hard time getting the correct derivative if it's as
complicated as these here. Don't be discouraged, however! Sagemath (making sure not to factor
anything) could correctly do out this math, even if I had a bit of a scare realizing that when I
was factoring it I was just being saved by `override_simulate` being accidentally set to true.
Anyways, use sagemath and jupyter notebook. I don't know if all sagemaths come with it
preinstalled, but nix makes it so easy that all I have to do is `sage -n jupyter` and it'll open it
right up. `%display latex` in jupiter makes it look pretty, whereas `%display ascii_art` will make
it look *presentable* in tui sagemath.
The derivative (via sagemath) is as follows:
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}f^\prime (x)=-\frac{20}{3} \, \pi 2^{10 \, x - 10} \cos\left(-\frac{43}{6} \, \pi %2B \frac{20}{3} \, \pi x\right) - 10 \cdot 2^{10 \, x - 10} \log\left(2\right) \sin\left(-\frac{43}{6} \, \pi %2B \frac{20}{3} \, \pi x\right)">
4. Ensure that `(0,0) ∈ f'`
Quadratic: `2*0 = 0` so we're good
Ease in elastic not so much, however:
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}f^\prime (0)=\frac{5}{1536} \, \sqrt{3} \pi - \frac{5}{1024} \, \log\left(2\right)">
We'll subtract this value from `f(x)` so that our new `f(x)`, let's say `f_2(x)` is such that `(0,0) ∈ f_2`
5. Ensure that `(1,1) ∈ f_2`
Quadratic: This means we have to do a wee bit of work: `f(1)=2`, so to counteract this,
we'll create a new (and final) function that we can call `f_e` (easing function) by dividing `f(x)`
by `f(1)` (scaling it down).
```
f(1)=2
f(x)/f(1) = 2x / 2 = x,
f_e(x)=x
```
Easy as that!
Or so you thought. Now let's check the same for ease in elastic:
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}f_2(1)=-\frac{5}{1536} \, \sqrt{3} \pi %2B \frac{10245}{1024} \, \log\left(2\right)">
Hence the need for sagemath. Once we divide the two we get our final easing function, this:
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}f_e(x)=\frac{4096 \, \pi 2^{10 \, x - 10} \cos\left(-\frac{43}{6} \, \pi %2B \frac{20}{3} \, \pi x\right) %2B 6144 \cdot 2^{10 \, x - 10} \log\left(2\right) \sin\left(-\frac{43}{6} \, \pi %2B \frac{20}{3} \, \pi x\right) %2B 2 \, \sqrt{3} \pi - 3 \, \log\left(2\right)}{2 \, \sqrt{3} \pi - 6147 \, \log\left(2\right)}">
What on god's green earth is that. Well whatever, at least it works.
6. Finally, we get the definite integral from 0 to 1 of our `f(x)`
For `f(x)=x` we can do that in our heads, it's just `1/2`.
Ease in elastic is a bit trickier to do in your head. You can do this with sagemath and eventually get this:
<img src="https://render.githubusercontent.com/render/math?math=\color{blue}\frac{20 \, \sqrt{3} \pi - 30 \, \log\left(2\right) - 6147}{10 \, {\left(2 \, \sqrt{3} \pi - 6147 \, \log\left(2\right)\right)}}">
So this all looked pretty daunting probably, and to be honest it took me hours of either not using
sage (I tried with wolfram alpha for a good hour) or using sage incorrectly (it took three months
to realize that this entire section of the readme was wrong and that using `factor` made it
incorrect), but now that I have this easy little code snippet you can use for sage it shouldn't be
as much of a hastle for you.
```python
from sage.symbolic.integration.integral import definite_integral
function('f')
f(x)='''your function goes here'''
f(x)=derivative(f(x), x)
f(x)=f(x)-f(0)
f(x)=f(x)/f(1)
print(f(x)) # easing
print(definite_integral(f(x), x, 0, 1)) # F
```
So the thing with using `factor` is that, while on some weird other version of sage I was geting a
bunch of 0.49999s which wouldn't round to .5, the result was straight up wrong. So I advise against
it, and if you can't do the derivative then sucks to suck I guess (just lmk in an issue or
something and I'll try my very best).
7. Now we just have to translate this into an actual lua table.
Quadratic, as usual, is easy.
```lua
local quadratic = {
F = 1/2 -- F(1) = 1/2
easing = function(t) return t end -- f(x) = x, I just use t for "time"
}
```
Ease in elastic, as usual, is not. At one point I had the willpower to try and optimize operations,
but I really don't want to simplify those equations and I can't trust `factor`, so for now it stays
as is. If it irks you, make a pull request and save us both.
```lua
local bouncy = {
F = (20*math.sqrt(3)*math.pi-30*math.log(2)-6147) /
(10*(2*math.sqrt(3)*math.pi-6147*math.log(2))),
easing = function(t) return
(4096*math.pi*math.pow(2, 10*t-10)*math.cos(20/3*math.pi*t-43/6*math.pi)
+6144*math.pow(2, 10*t-10)*math.log(2)*math.sin(20/3*math.pi*t-43/6*math.pi)
+2*math.sqrt(3)*math.pi-3*math.log(2)) /
(2*math.pi*math.sqrt(3)-6147*math.log(2))
end
}
-- how it would actually look in a timed object
timed = rubato.timed {
intro = 0, --we'll use this as an outro, since it's weird as an intro
outro = 0.7,
duration = 1,
easing = bouncy
}
```
We did it! Now to check whether or not it actually works
![Beautiful](./images/beautiful.gif)
While you can't see its full glory in 25 fps gif form, it really is pretty cool. Furthermore, if it
works with *that* function, it'll probably work with anything. As long as you have the correct
antiderivative and it's properly scaled, you can probably use any (real, differentiable) function
under the sun.
Note that if it's not properly scaled, this can be worked around (if you're lazy and don't care
about a bit of a performance decrease). You can set `override_simulaton` to true. However, it is
possible that it will not perform exactly as you expected if you do this so do your best to just
find the derivative and antiderivative of the derivative.
<h1 id="install">Installation</h1>
So actually telling people how to install this is important, isn't it
It supports luarocks, so that'll cut it if you want a really really easy install, but it'll install
it in some faraway lua bin where you'll probably leave it forever if you either stop using rubato or
stop using awesome. However, it's certainly the easiest way to go about it. I personally don't like
doing this much because it adds it globally and I'm only gonna be using this with awesome, but it's
a really easy install.
```
luarocks install rubato
```
Otherwise, somewhere in your awesome directory, (I use `~/.config/awesome/lib`) you can run this
command:
```
git clone https://github.com/andOrlando/rubato.git
```
Then, whenever you actually want to use rubato, do this at the start of the lua file: `local rubato
= require "lib.rubato"`
<h1 id="name">Why the name?</h1>
Because I play piano so this kinda links up with other stuff I do, and rubato really well fits the
project. In music, it means "push and pull of tempo" basically, which really is what easing is all
about in the first place. Plus, it'll be the first of my projects without garbage names
("minesweperSweeper," "Latin Learning").
<h1 id="todo">Todo</h1>
- [ ] add `target` function, which rather than a set time has a set distance.
- [x] improve intro and outro arguments (asserts, default values, proportional intros/outros)
- [x] get a better name... (I have a cool name now!)
- [x] make readme cooler
- [x] have better documentation and add to luarocks
- [x] remove gears dependency
- [ ] only apply corrective coefficient to plateau
- [x] Do `prop_intro` more intelligently so it doesn't have to do so many comparisons (done maybe kinda?)
- [x] Make things like `abort` more useful
- [x] Merge that pr by @Kasper so instant works
- [x] Add a manager (this proceeds the above todo thing)
- [ ] Make forall more useable and add tags and stuff
- [ ] Fix that bug where you could set stuff manually (this might already be fixed I just haven't tested it)
- [ ] Make is_instant even faster by just short circuiting `set`

Some files were not shown because too many files have changed in this diff Show more