Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "polybar-mic-volume"]
path = polybar-mic-volume
url = https://github.com/MarcDonald/polybar-mic-volume.git
9 changes: 9 additions & 0 deletions bin/count_rotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const net = require('net');

const client = new net.Socket();
client.connect("/tmp/rofi_notification_daemon",() => client.write('num\n'));

client.on('data', function(data) {
console.log(data.toString().split(",")[0]);
client.destroy();
});
17 changes: 17 additions & 0 deletions bin/count_rotification.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
#/home/infra/me/regolith-rofication/rofication-daemon

# 936 type = custom/script
# 937 exec = /home/infra/me/regolith-rofication/count_rofi_notification
# 938 format-prefix = 

import socket
import sys
server_address = '/tmp/rofi_notification_daemon'
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(server_address)
sock.send(b'num\n')

response = sock.recv(1024)

print(response.decode().split(",")[0])
26 changes: 26 additions & 0 deletions bin/i3-cycle-tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const execSync = require('child_process').execSync;

const args = process.argv.slice(2)
const windowIndex = parseInt(args[0])
const state = JSON.parse(execSync(`swaymsg -t get_tree`))

const currentWorkspace = state.nodes;

function getLeaves(root) {
const nodes = root.nodes;
const results = [];
while (nodes.length) {
const node = nodes.shift()
if (node.nodes.length > 0) {
nodes.push(...node.nodes)
} else {
results.push(node)
}
}
return results
}

const programNodes = getLeaves(state)
const unfocusedVisibledWindow = programNodes.find(p => p.visible && !p.focused)
execSync(`swaymsg '[con_id="${unfocusedVisibledWindow.id}"] focus'`)

11 changes: 11 additions & 0 deletions bin/i3-select-tab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const execSync = require('child_process').execSync;

const args = process.argv.slice(2)
const windowIndex = parseInt(args[0])
const state = JSON.parse(execSync(`swaymsg -t get_tree`))

const currentWorkspace = parseInt(state.nodes.flat().find(i => i.active).current_workspace)
const nodes = state.nodes.find(i => i.active).nodes[0].nodes
const window = windowIndex == -1? nodes.pop() : nodes[windowIndex]

execSync(`swaymsg '[con_id="${window.id}"] focus'`)
7 changes: 0 additions & 7 deletions bin/i3-tab.sh

This file was deleted.

29 changes: 29 additions & 0 deletions bin/mic-volume.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// # 0 8,12,23 * * * /home/infra/me/mydotfiles/bin/wallpaper.js

const https = require('https');
const fs = require('fs');
const execSync = require('child_process').execSync;
const output = execSync(`amixer -c 0`).toString().trim().split("\n")
function parseAmixer(output) {
const result = {}
let lastKey;
output.forEach(line => {
if(line[0]!==" ") {
const startIndex = line.indexOf("'")+1
const endIndex = line.indexOf(",")-1

lastKey=line.slice(startIndex,endIndex)
result[lastKey]={}
} else {
const [key, value] = line.split(":")
result[lastKey][key.trim()]=value.trim()
}
})
return result
}


const mic = parseAmixer(output)
const rawValue = mic['Headset Mic Boost']['Front Left']
const value = (/(\d*)%/).exec(rawValue)[0]
console.log(value)
63 changes: 63 additions & 0 deletions bin/wallpaper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// # 0 8,12,23 * * * /home/infra/me/mydotfiles/bin/wallpaper.js

const https = require('https');
const fs = require('fs');
const execSync = require('child_process').execSync;

const displays = ["eDP-1","eHDMI-1"]

function streamToString(stream) {
const chunks = [];
return new Promise((resolve, reject) => {
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
stream.on('error', (err) => reject(err));
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
})
}

function downloadImage(url, ext) {
return new Promise((resolve, reject) => https.get(url, resolve))
}

function getWallpaperStream() {
return new Promise((resolve, reject) => https.get("https://www.reddit.com/r/earthporn.json?sort=new", resolve))
}

async function saveFile(stream, fileName) {
return new Promise((resolve, reject) => {
stream.pipe(fs.createWriteStream(fileName))
stream.on('error', reject);
stream.on('end', resolve);
})
}

function isValidImage(i) {
const data = i.data
const {width, height} = data.preview.images[0].source
return data.url_overridden_by_dest && width > height
}

async function main() {
try {
const wallpapersStream = await getWallpaperStream();
const wallpapersRestResponse = JSON.parse(await streamToString(wallpapersStream))
const wallpapers = wallpapersRestResponse.data.children.filter(isValidImage).slice(0,2).map(i => i.data.url_overridden_by_dest)
const homePath = process.env.HOME

const wallpaperPaths = wallpapers.map(async (wallpaper, i)=> {
const wallpaperStream = await downloadImage(wallpaper)
const extension = wallpaper.split(".").pop()
const wallpaperFile = `${homePath}/.wallpaper${i}.${extension}`
await saveFile(wallpaperStream, wallpaperFile)
return wallpaperFile
})

const paths = await Promise.all(wallpaperPaths)
paths.forEach( (wallpaperPath,i) => execSync(`swaymsg output "${displays[i]}" background ${wallpaperPath} fill`))

} catch (error) {
console.log(error)
}
}

main()
20 changes: 0 additions & 20 deletions bin/wallpaper.sh

This file was deleted.

Loading