mirror of
https://github.com/aminnairi/dotfiles.git
synced 2026-09-14 16:52:12 +02:00
huge rework in order to take full advantage of ansible roles
This commit is contained in:
@@ -0,0 +1,251 @@
|
||||
# This file has been auto-generated by i3-config-wizard(1).
|
||||
# It will not be overwritten, so edit it as you like.
|
||||
#
|
||||
# Should you change your keyboard layout some time, delete
|
||||
# this file and re-run i3-config-wizard(1).
|
||||
#
|
||||
|
||||
# i3 config file (v4)
|
||||
#
|
||||
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
|
||||
|
||||
set $mod Mod4
|
||||
|
||||
# Font for window titles. Will also be used by the bar unless a different font
|
||||
# is used in the bar {} block below.
|
||||
font pango:JetBrains Mono Nerd Font 14
|
||||
|
||||
# This font is widely installed, provides lots of unicode glyphs, right-to-left
|
||||
# text rendering and scalability on retina/hidpi displays (thanks to pango).
|
||||
#font pango:DejaVu Sans Mono 8
|
||||
|
||||
# Start XDG autostart .desktop files using dex. See also
|
||||
# https://wiki.archlinux.org/index.php/XDG_Autostart
|
||||
exec --no-startup-id dex --autostart --environment i3
|
||||
|
||||
# The combination of xss-lock, nm-applet and pactl is a popular choice, so
|
||||
# they are included here as an example. Modify as you see fit.
|
||||
|
||||
# xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
|
||||
# screen before suspend. Use loginctl lock-session to lock your screen.
|
||||
exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock-fancy --nofork --font Noto-Sans-Regular --text "Welcome, Amin NAIRI"
|
||||
|
||||
# NetworkManager is the most popular way to manage wireless networks on Linux,
|
||||
# and nm-applet is a desktop environment-independent system tray GUI for it.
|
||||
exec --no-startup-id nm-applet
|
||||
|
||||
# PulseAudio system tray volume indicator
|
||||
exec --no-startup-id pasystray
|
||||
|
||||
# Use pactl to adjust volume in PulseAudio.
|
||||
set $refresh_i3status killall -SIGUSR1 i3status
|
||||
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
|
||||
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
|
||||
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
|
||||
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
|
||||
|
||||
# Use Mouse+$mod to drag floating windows to their wanted position
|
||||
floating_modifier $mod
|
||||
|
||||
# move tiling windows via drag & drop by left-clicking into the title bar,
|
||||
# or left-clicking anywhere into the window while holding the floating modifier.
|
||||
tiling_drag modifier titlebar
|
||||
|
||||
# Alignment of the top title of a window (left, center or right)
|
||||
title_align center
|
||||
|
||||
# start a terminal
|
||||
bindsym $mod+Return exec kitty
|
||||
|
||||
# kill focused window
|
||||
bindsym $mod+Shift+q kill
|
||||
|
||||
# start dmenu (a program launcher)
|
||||
# bindsym $mod+d exec --no-startup-id dmenu_run
|
||||
|
||||
# A more modern dmenu replacement is rofi:
|
||||
bindsym $mod+d exec "rofi -modi drun,run -show drun"
|
||||
# There also is i3-dmenu-desktop which only displays applications shipping a
|
||||
# .desktop file. It is a wrapper around dmenu, so you need that installed.
|
||||
# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop
|
||||
|
||||
# change focus
|
||||
bindsym $mod+j focus left
|
||||
bindsym $mod+k focus down
|
||||
bindsym $mod+l focus up
|
||||
bindsym $mod+semicolon focus right
|
||||
|
||||
# alternatively, you can use the cursor keys:
|
||||
bindsym $mod+Left focus left
|
||||
bindsym $mod+Down focus down
|
||||
bindsym $mod+Up focus up
|
||||
bindsym $mod+Right focus right
|
||||
|
||||
# move focused window
|
||||
bindsym $mod+Shift+j move left
|
||||
bindsym $mod+Shift+k move down
|
||||
bindsym $mod+Shift+l move up
|
||||
bindsym $mod+Shift+semicolon move right
|
||||
|
||||
# alternatively, you can use the cursor keys:
|
||||
bindsym $mod+Shift+Left move left
|
||||
bindsym $mod+Shift+Down move down
|
||||
bindsym $mod+Shift+Up move up
|
||||
bindsym $mod+Shift+Right move right
|
||||
|
||||
# split in horizontal orientation
|
||||
bindsym $mod+h split h
|
||||
|
||||
# split in vertical orientation
|
||||
bindsym $mod+v split v
|
||||
|
||||
# enter fullscreen mode for the focused container
|
||||
bindsym $mod+f fullscreen toggle
|
||||
|
||||
# change container layout (stacked, tabbed, toggle split)
|
||||
bindsym $mod+s layout stacking
|
||||
bindsym $mod+w layout tabbed
|
||||
bindsym $mod+e layout toggle split
|
||||
|
||||
# toggle tiling / floating
|
||||
bindsym $mod+Shift+space floating toggle
|
||||
|
||||
# change focus between tiling / floating windows
|
||||
bindsym $mod+space focus mode_toggle
|
||||
|
||||
# focus the parent container
|
||||
bindsym $mod+a focus parent
|
||||
|
||||
# focus the child container
|
||||
#bindsym $mod+d focus child
|
||||
|
||||
# Define names for default workspaces for which we configure key bindings later on.
|
||||
# We use variables to avoid repeating the names in multiple places.
|
||||
set $ws1 "1"
|
||||
set $ws2 "2"
|
||||
set $ws3 "3"
|
||||
set $ws4 "4"
|
||||
set $ws5 "5"
|
||||
set $ws6 "6"
|
||||
set $ws7 "7"
|
||||
set $ws8 "8"
|
||||
set $ws9 "9"
|
||||
set $ws10 "10"
|
||||
|
||||
# switch to workspace
|
||||
bindsym $mod+1 workspace number $ws1
|
||||
bindsym $mod+2 workspace number $ws2
|
||||
bindsym $mod+3 workspace number $ws3
|
||||
bindsym $mod+4 workspace number $ws4
|
||||
bindsym $mod+5 workspace number $ws5
|
||||
bindsym $mod+6 workspace number $ws6
|
||||
bindsym $mod+7 workspace number $ws7
|
||||
bindsym $mod+8 workspace number $ws8
|
||||
bindsym $mod+9 workspace number $ws9
|
||||
bindsym $mod+0 workspace number $ws10
|
||||
|
||||
# move focused container to workspace
|
||||
bindsym $mod+Shift+1 move container to workspace number $ws1
|
||||
bindsym $mod+Shift+2 move container to workspace number $ws2
|
||||
bindsym $mod+Shift+3 move container to workspace number $ws3
|
||||
bindsym $mod+Shift+4 move container to workspace number $ws4
|
||||
bindsym $mod+Shift+5 move container to workspace number $ws5
|
||||
bindsym $mod+Shift+6 move container to workspace number $ws6
|
||||
bindsym $mod+Shift+7 move container to workspace number $ws7
|
||||
bindsym $mod+Shift+8 move container to workspace number $ws8
|
||||
bindsym $mod+Shift+9 move container to workspace number $ws9
|
||||
bindsym $mod+Shift+0 move container to workspace number $ws10
|
||||
|
||||
# reload the configuration file
|
||||
bindsym $mod+Shift+c reload
|
||||
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
||||
bindsym $mod+Shift+r restart
|
||||
# exit i3 (logs you out of your X session)
|
||||
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
|
||||
|
||||
# Set gaps
|
||||
gaps inner 20
|
||||
|
||||
# resize window (you can also use the mouse for that)
|
||||
mode "resize" {
|
||||
# These bindings trigger as soon as you enter the resize mode
|
||||
|
||||
# Pressing left will shrink the window’s width.
|
||||
# Pressing right will grow the window’s width.
|
||||
# Pressing up will shrink the window’s height.
|
||||
# Pressing down will grow the window’s height.
|
||||
bindsym j resize shrink width 10 px or 10 ppt
|
||||
bindsym k resize grow height 10 px or 10 ppt
|
||||
bindsym l resize shrink height 10 px or 10 ppt
|
||||
bindsym semicolon resize grow width 10 px or 10 ppt
|
||||
|
||||
# same bindings, but for the arrow keys
|
||||
bindsym Left resize shrink width 10 px or 10 ppt
|
||||
bindsym Down resize grow height 10 px or 10 ppt
|
||||
bindsym Up resize shrink height 10 px or 10 ppt
|
||||
bindsym Right resize grow width 10 px or 10 ppt
|
||||
|
||||
# back to normal: Enter or Escape or $mod+r
|
||||
bindsym Return mode "default"
|
||||
bindsym Escape mode "default"
|
||||
bindsym $mod+r mode "default"
|
||||
}
|
||||
|
||||
bindsym $mod+r mode "resize"
|
||||
|
||||
# Lock the screen when hitting the Super+x keybind
|
||||
bindsym $mod+x exec i3lock-fancy --nofork --font 'Noto-Sans-Regular' --text "Welcome Amin NAIRI"
|
||||
|
||||
# Use Flameshot when hitting the Super+p keybind
|
||||
bindsym $mod+p exec flameshot gui
|
||||
|
||||
# Show emoji when hitting Super+m keybind
|
||||
bindsym $mod+m exec --no-startup-id rofi -modi emoji -show emoji -emoji-format '{emoji}'
|
||||
|
||||
# Use Rofi-rbw to copy password to clipboard when hitting Super+b keybind
|
||||
bindsym $mod+b exec --no-startup-id rofi-rbw
|
||||
|
||||
# Use Xbacklight to control brightness
|
||||
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 5
|
||||
bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 5
|
||||
|
||||
# Use Playerctl to control music
|
||||
bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause
|
||||
bindsym XF86AudioNext exec --no-startup-id playerctl next
|
||||
bindsym XF86AudioPrev exec --no-startup-id playerctl previous
|
||||
bindsym XF86AudioStop exec --no-startup-id playerctl stop
|
||||
|
||||
# Window coloring
|
||||
# class border backgr. text indicator child_border
|
||||
client.focused #24283b #24283b #c0caf5 #c0caf5 #285577
|
||||
client.focused_inactive #333333 #5f676a #ffffff #484e50 #5f676a
|
||||
client.unfocused #333333 #222222 #888888 #292d2e #222222
|
||||
client.urgent #2f343a #900000 #ffffff #900000 #900000
|
||||
client.placeholder #000000 #0c0c0c #ffffff #000000 #0c0c0c
|
||||
|
||||
client.background #ffffff
|
||||
|
||||
# Start i3bar to display a workspace bar (plus the system information i3status
|
||||
# finds out, if available)
|
||||
bar {
|
||||
status_command node $HOME/.config/i3/i3status
|
||||
|
||||
# Padding top, bottom, left & right
|
||||
padding 3px
|
||||
|
||||
# Position of the bar relative to the screen (top or bottom)
|
||||
position top
|
||||
|
||||
colors {
|
||||
background #24283b
|
||||
statusline #c0caf5
|
||||
separator #666666
|
||||
|
||||
# Location Border Background Text
|
||||
focused_workspace #24283b #24283b #c0caf5
|
||||
active_workspace #7aa2f7 #5f676a #1f2335
|
||||
inactive_workspace #24283b #24283b #666666
|
||||
urgent_workspace #24283b #c0caf5 #24283b
|
||||
binding_mode #c0caf5 #24283b #c0caf5
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
import { URL } from "url";
|
||||
import { request } from "https";
|
||||
import { readFile } from "fs/promises";
|
||||
import { cpus as cpuInfo, homedir } from "os";
|
||||
import { exec } from "child_process";
|
||||
import { createInterface } from "readline/promises";
|
||||
import { stdin as input, stdout as output } from "process";
|
||||
import { createRenderer } from "@aminnairi/i3status";
|
||||
import { join } from "path";
|
||||
|
||||
// SETTINGS
|
||||
|
||||
const settings = await readFile(join(homedir(), ".config/i3/i3status/settings.json")).then(fileContent => {
|
||||
return JSON.parse(fileContent);
|
||||
}).catch(() => {
|
||||
return {
|
||||
weather: {
|
||||
appid: ""
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// HELPERS
|
||||
|
||||
const toHexadecimal = (number) => {
|
||||
const hexadecimal = number.toString(16);
|
||||
|
||||
return hexadecimal.length === 1
|
||||
? `0${hexadecimal}`
|
||||
: hexadecimal;
|
||||
};
|
||||
|
||||
const getHexadecimalColorBetween = (color1, color2, ratio) => {
|
||||
const red = Math.round(color1.red + (color2.red - color1.red) * ratio);
|
||||
const green = Math.round(color1.green + (color2.green - color1.green) * ratio);
|
||||
const blue = Math.round(color1.blue + (color2.blue - color1.blue) * ratio);
|
||||
|
||||
return `#${toHexadecimal(red)}${toHexadecimal(green)}${toHexadecimal(blue)}`;
|
||||
};
|
||||
|
||||
const red = {
|
||||
red: 255,
|
||||
green: 0,
|
||||
blue: 0
|
||||
};
|
||||
|
||||
const green = {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0
|
||||
};
|
||||
|
||||
const json = {
|
||||
get: (url) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { hostname, pathname, search } = new URL(url);
|
||||
const path = `${pathname}${search}`;
|
||||
|
||||
let data = "";
|
||||
|
||||
const req = request({
|
||||
hostname,
|
||||
path,
|
||||
port: 443,
|
||||
method: "GET"
|
||||
}, response => {
|
||||
response.on("data", chunk => {
|
||||
data += chunk.toString();
|
||||
});
|
||||
|
||||
response.on("end", () => {
|
||||
try {
|
||||
resolve(JSON.parse(data));
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on("error", error => {
|
||||
reject(error);
|
||||
});
|
||||
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const execute = (command) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
return reject(new Error(stderr));
|
||||
}
|
||||
|
||||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const ignore = () => { };
|
||||
|
||||
// BUSINESS
|
||||
|
||||
const getCov19 = async () => {
|
||||
return json.get("https://coronavirusapifr.herokuapp.com/data/live/france").then(response => {
|
||||
return ` ${Math.round(response[0].TO * 10000) / 100}%`;
|
||||
});
|
||||
};
|
||||
|
||||
const getClock = () => {
|
||||
const date = new Date();
|
||||
return ` ${date.toLocaleDateString("fr-FR")} ${date.toLocaleTimeString("fr-FR")}`;
|
||||
};
|
||||
|
||||
const getBitcoinRate = async () => {
|
||||
return json.get("https://api.coindesk.com/v1/bpi/currentprice.json").then(json => {
|
||||
return ` ${json.bpi.USD.rate}`;
|
||||
});
|
||||
};
|
||||
|
||||
const getWeather = async () => {
|
||||
return json.get(`https://api.openweathermap.org/data/2.5/weather?q=paris&appid=${settings.weather.appid}&units=metric`).then(json => {
|
||||
return ` ${Math.round((Number(json.main.temp) || 0) * 10) / 10}°C ${json.weather[0].main}`;
|
||||
});
|
||||
};
|
||||
|
||||
const getCpus = () => {
|
||||
const cpus = cpuInfo();
|
||||
const count = cpus.length;
|
||||
const speed = Math.round(cpus.reduce((clock, cpu) => clock + cpu.speed, 0) / count) / 1000;
|
||||
|
||||
return ` ${count} CPUs ${speed}GHz`;
|
||||
};
|
||||
|
||||
const getBattery = async () => {
|
||||
return Promise.all([
|
||||
execute("/usr/bin/cat /sys/class/power_supply/BAT*/capacity"),
|
||||
execute("/usr/bin/cat /sys/class/power_supply/BAT*/status")
|
||||
]).then(([rawBattery, rawStatus]) => {
|
||||
const battery = Number(rawBattery.trim()) || 0;
|
||||
const status = rawStatus.trim();
|
||||
const icon = status === "Discharging" ? "" : "";
|
||||
const color = status === "Discharging" ? getHexadecimalColorBetween(red, green, battery / 100) : "#00FF00";
|
||||
|
||||
return {
|
||||
color,
|
||||
full_text: `${icon} ${battery}%`
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getBrightness = async () => {
|
||||
return execute("/usr/bin/cat /sys/class/backlight/*/brightness").then(brightness => {
|
||||
const brightnessLevel = Number(brightness.trim()) || 0;
|
||||
|
||||
return ` ${brightnessLevel}%`;
|
||||
});
|
||||
};
|
||||
|
||||
const getVolume = async () => {
|
||||
return Promise.all([
|
||||
execute("pactl get-sink-volume @DEFAULT_SINK@ | grep 'Volume' | cut -d '/' -f 2"),
|
||||
execute("pactl get-sink-mute @DEFAULT_SINK@")
|
||||
]).then(([volume, muted]) => {
|
||||
return `${muted.includes("no") ? "" : ""} ${volume.trim()}`;
|
||||
});
|
||||
};
|
||||
|
||||
const getMemory = async () => {
|
||||
return Promise.all([
|
||||
execute("grep MemTotal /proc/meminfo | cut -d ' ' -f 8"),
|
||||
execute("grep MemAvailable /proc/meminfo | cut -d ' ' -f 5")
|
||||
]).then(([rawTotalMemory, rawAvailableMemory]) => {
|
||||
const totalMemory = Math.round((Number(rawTotalMemory.trim()) || 0) / 100000) / 10;
|
||||
const freeMemory = Math.round((Number(rawAvailableMemory.trim()) || 0) / 100000) / 10;
|
||||
|
||||
return ` ${freeMemory}Go / ${totalMemory}Go`;
|
||||
});
|
||||
};
|
||||
|
||||
const getDiskSpace = async () => {
|
||||
return Promise.all([
|
||||
execute("df -h | grep '/\$' | cut -d ' ' -f 7"),
|
||||
execute("df -h | grep '/\$' | cut -d ' ' -f 3")
|
||||
]).then(([rawDiskSpaceRemaining, rawDiskSpaceTotal]) => {
|
||||
const diskSpaceRemaining = rawDiskSpaceRemaining.trim();
|
||||
const diskSpaceTotal = rawDiskSpaceTotal.trim();
|
||||
|
||||
return ` ${diskSpaceRemaining} / ${diskSpaceTotal}`;
|
||||
});
|
||||
};
|
||||
|
||||
// SETUP
|
||||
|
||||
const render = createRenderer({
|
||||
createInterface,
|
||||
input,
|
||||
output
|
||||
});
|
||||
|
||||
const dispatch = render({
|
||||
initialBlocks: [
|
||||
{
|
||||
name: "disk",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "memory",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "cpus",
|
||||
full_text: getCpus(),
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "bitcoin",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "cov19",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "weather",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "battery",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "brightness",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "volume",
|
||||
full_text: "",
|
||||
separator: false
|
||||
},
|
||||
{
|
||||
name: "clock",
|
||||
full_text: getClock(),
|
||||
separator: false
|
||||
},
|
||||
],
|
||||
onEvent: ({ event: { name, button, modifiers }, dispatch }) => {
|
||||
const leftClick = 1;
|
||||
|
||||
if (name === "clock" && button === leftClick && modifiers.length === 1 && modifiers.includes("Control")) {
|
||||
return execute("librewolf https://calendar.google.com");
|
||||
}
|
||||
|
||||
if (name === "weather" && button === 1 && modifiers.length === 0) {
|
||||
return getWeather().then(weather => {
|
||||
dispatch({
|
||||
name: "WEATHER_SET_FULL_TEXT",
|
||||
payload: weather
|
||||
});
|
||||
}).catch(ignore);
|
||||
}
|
||||
|
||||
if (name === "bitcoin" && button === 1) {
|
||||
if (modifiers.length === 0) {
|
||||
return getBitcoinRate().then(rate => {
|
||||
dispatch({
|
||||
name: "BITCOIN_SET_FULL_TEXT",
|
||||
payload: rate
|
||||
});
|
||||
}).catch(ignore);
|
||||
}
|
||||
|
||||
if (modifiers.length === 1 && modifiers.includes("Control")) {
|
||||
return execute("librewolf https://coindesk.com/price/bitcoin");
|
||||
}
|
||||
}
|
||||
},
|
||||
onDispatch: ({ blocks, action: { name, payload } }) => {
|
||||
switch (name) {
|
||||
case "CLOCK_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "clock") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
})
|
||||
|
||||
case "BITCOIN_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "bitcoin") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "WEATHER_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "weather") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "CPUS_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "cpus") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "BATTERY_SET_FULL_TEXT_COLOR":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "battery") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload.full_text,
|
||||
color: payload.color
|
||||
};
|
||||
});
|
||||
|
||||
case "BRIGHTNESS_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "brightness") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "VOLUME_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "volume") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "MEMORY_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "memory") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "DISK_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "disk") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
case "COV19_SET_FULL_TEXT":
|
||||
return blocks.map(block => {
|
||||
if (block.name !== "cov19") {
|
||||
return block;
|
||||
}
|
||||
|
||||
return {
|
||||
...block,
|
||||
full_text: payload
|
||||
};
|
||||
});
|
||||
|
||||
default:
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// INTERVALS
|
||||
|
||||
setInterval(() => {
|
||||
dispatch({
|
||||
name: "CLOCK_SET_FULL_TEXT",
|
||||
payload: getClock()
|
||||
});
|
||||
|
||||
dispatch({
|
||||
name: "CPUS_SET_FULL_TEXT",
|
||||
payload: getCpus()
|
||||
});
|
||||
|
||||
getBattery().then(battery => {
|
||||
dispatch({
|
||||
name: "BATTERY_SET_FULL_TEXT_COLOR",
|
||||
payload: battery
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getBrightness().then(brightness => {
|
||||
dispatch({
|
||||
name: "BRIGHTNESS_SET_FULL_TEXT",
|
||||
payload: brightness
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getVolume().then(volume => {
|
||||
dispatch({
|
||||
name: "VOLUME_SET_FULL_TEXT",
|
||||
payload: volume
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getMemory().then(memory => {
|
||||
dispatch({
|
||||
name: "MEMORY_SET_FULL_TEXT",
|
||||
payload: memory
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getDiskSpace().then(diskSpace => {
|
||||
dispatch({
|
||||
name: "DISK_SET_FULL_TEXT",
|
||||
payload: diskSpace
|
||||
});
|
||||
}).catch(ignore);
|
||||
}, 1000);
|
||||
|
||||
setInterval(() => {
|
||||
getBitcoinRate().then(rate => {
|
||||
dispatch({
|
||||
name: "BITCOIN_SET_FULL_TEXT",
|
||||
payload: rate
|
||||
});
|
||||
}).catch(ignore);
|
||||
}, 1000 * 60 * 10);
|
||||
|
||||
setInterval(() => {
|
||||
getWeather().then(weather => {
|
||||
dispatch({
|
||||
name: "WEATHER_SET_FULL_TEXT",
|
||||
payload: weather
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
}, 1000 * 60 * 30);
|
||||
|
||||
setInterval(() => {
|
||||
getCov19().then(payload => {
|
||||
dispatch({
|
||||
name: "COV19_SET_FULL_TEXT",
|
||||
payload
|
||||
});
|
||||
}).catch(ignore);
|
||||
}, 1000 * 60 * 60 * 12);
|
||||
|
||||
// INITIAL SETUP
|
||||
|
||||
getBitcoinRate().then(rate => {
|
||||
dispatch({
|
||||
name: "BITCOIN_SET_FULL_TEXT",
|
||||
payload: rate
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getWeather().then(weather => {
|
||||
dispatch({
|
||||
name: "WEATHER_SET_FULL_TEXT",
|
||||
payload: weather
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getBattery().then(battery => {
|
||||
dispatch({
|
||||
name: "BATTERY_SET_FULL_TEXT_COLOR",
|
||||
payload: battery
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getBrightness().then(brightness => {
|
||||
dispatch({
|
||||
name: "BRIGHTNESS_SET_FULL_TEXT",
|
||||
payload: brightness
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getVolume().then(volume => {
|
||||
dispatch({
|
||||
name: "VOLUME_SET_FULL_TEXT",
|
||||
payload: volume
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getMemory().then(memory => {
|
||||
dispatch({
|
||||
name: "MEMORY_SET_FULL_TEXT",
|
||||
payload: memory
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getDiskSpace().then(diskSpace => {
|
||||
dispatch({
|
||||
name: "DISK_SET_FULL_TEXT",
|
||||
payload: diskSpace
|
||||
});
|
||||
}).catch(ignore);
|
||||
|
||||
getCov19().then(payload => {
|
||||
dispatch({
|
||||
name: "COV19_SET_FULL_TEXT",
|
||||
payload
|
||||
});
|
||||
}).catch(ignore);
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@aminnairi/i3status": "1.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"weather": {
|
||||
"appid": "150bbc4bae133cc448cba94e05b66703"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: Install i3-gaps (window manager)
|
||||
become: true
|
||||
pacman:
|
||||
name: i3-gaps
|
||||
state: present
|
||||
- name: Install i3lock-fancy (window locker)
|
||||
become: true
|
||||
kewlfft.aur.aur:
|
||||
name: i3lock-fancy
|
||||
state: present
|
||||
update_cache: true
|
||||
- name: Install Network Manager Applet (Network Manager i3status icon)
|
||||
become: true
|
||||
pacman:
|
||||
name: network-manager-applet
|
||||
state: present
|
||||
- name: Setup i3 Window Manager
|
||||
synchronize:
|
||||
src: i3
|
||||
dest: /$HOME/.config
|
||||
- name: Install custom i3status dependencies
|
||||
npm:
|
||||
path: /$HOME/.config/i3/i3status
|
||||
state: present
|
||||
Reference in New Issue
Block a user