Browse Source

Update

pull/19/head
Harish Karumuthil 2 years ago
parent
commit
68d3c3c06a
  1. 150
      home/.local/Apps/daily-utils/bin/sway-wp-switch
  2. 1
      home/.local/Apps/daily-utils/binaries.lst
  3. 3
      home/.node_modules_mine/.yarnrc.yml
  4. 106
      home/.node_modules_mine/package.json
  5. 47152
      home/.node_modules_mine/yarn.lock

150
home/.local/Apps/daily-utils/bin/sway-wp-switch

@ -0,0 +1,150 @@
#!/usr/bin/python3
import subprocess
import json
import math
def exec(cmd):
print('exec: ', cmd)
return subprocess.getoutput(cmd)
def getSwayInfo(cmd):
return json.loads(exec("swaymsg -t "+cmd))
class WpManager(object):
""""
* Workspace Manager
"""
def __init__(self,Rows, Cols, monitorCount):
w = 0
workspaces = []
r=0
while r < Rows:
c = 0
while c < Cols:
workspaces.append({
'left': c != 0 and w - 1,
'right': ( ( c + 1 ) != Cols ) and w + 1,
'up': ( r != 0 ) and ( w - Cols ),
'down': ( ( r + 1 ) != Rows ) and w + Cols
})
w=w+1
c=c+1
r=r+1
self.workspaces = workspaces
self.Rows = Rows
self.Cols = Cols
self.monitorCount = monitorCount
""""
* Workspace grid initialisation command generator.
* Currenlty not working because `Workspace` command will not work through `swaymsg`.
* it will work only if we put these commands on config file
"""
def getInitCmd (self):
outputs = [ v['name'] for v in getSwayInfo('get_outputs') if v['active']]
outputCout = len( outputs )
totalWorkspaces = self.Rows * self.Cols
cmd = []
ws=0
while ws < totalWorkspaces:
op = 0
while op < outputCout:
cmd.append("workspace " + str(ws * outputCout + op + 1) + " output "+outputs[op])
op=op+1
ws=ws+1
return ';\n'.join(cmd)
""""
* Return the list of target workspaces.
*
* Given current focused workspace and switching direction. eg: ( 1, down )
* for a 3x3 grid in a dual monitor, it will reutrn [ 7, 8 ].
* for single monitor setup, it will return [ 4 ]
* For three monitor setup, it will return [ 10, 11, 12 ]
*
* @param current - current monitor
* @param direction - direction up|down|right|left
* @returns {Array<Number>} - list of target workspaces
"""
def getWorkspaces (self,current, direction):
monitorCount = self.monitorCount
out = []
targetw = self.workspaces[math.ceil(current / monitorCount) - 1][direction]
if targetw is not False:
targetw = targetw * monitorCount
i = monitorCount
while i != 0:
out.append(targetw + i)
i=i-1
return out
""""
* Get swaymsg command for switching current Workspace to <direction> direction
*
* @param swayWorkspace
* @param direction
* @param isMove
* @returns {String} - swaymsg command
"""
def getCmd (self,swayWorkspace, direction, isMove):
currentWS = swayWorkspace['num']
currentOutput = swayWorkspace['output']
ws = self.getWorkspaces(currentWS, direction)
if not ws:
return
out = ["workspace %d"%v for v in ws ]
if isMove:
tws = ws[currentWS % self.monitorCount]
out.insert(0,"move container to workspace %d"%tws)
out.append("focus output "+currentOutput)
return '; '.join(out)
helpStr = '''
sway-wp-switch
Usage:
sway-wp-switch [ -m ] <up|down|right|left>
Options:
-m move current window to new workspace while switching.
If currently focused windows in output-2, it will be placed in output-two itself without losing focus
'''
def main():
import sys
direction = sys.argv[1]
isMove = False
ROWS = 3
COLS = 3
if direction == '-m':
isMove = True
direction = sys.argv[2]
if direction not in ['up', 'down', 'right', 'left', '-i']:
print(helpStr)
return
outputInfo = getSwayInfo('get_outputs')
outputInfo = [v for v in outputInfo if v['active'] ]
wm = WpManager(ROWS, COLS, len( outputInfo ))
if direction == '-i':
cmd = wm.getInitCmd()
print(cmd)
cmd=''
else:
workspaceInfo = next(v for v in getSwayInfo('get_workspaces') if v[ 'focused' ] )
cmd = wm.getCmd(workspaceInfo, direction, isMove)
if cmd:
exec('swaymsg -t command "%s"'% cmd)
main()

1
home/.local/Apps/daily-utils/binaries.lst

@ -6,3 +6,4 @@
./bin/dasel_linux_amd64
./bin/octosql
./bin/dsq
./bin/sway-wp-switch

3
home/.node_modules_mine/.yarnrc.yml

@ -0,0 +1,3 @@
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

106
home/.node_modules_mine/package.json

@ -0,0 +1,106 @@
{
"dependencies": {
"@babel/cli": "^7.22.5",
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@faker-js/faker": "^8.0.2",
"@ionic/cli": "^7.1.1",
"@nestjs/cli": "^10.1.0",
"@openapitools/openapi-generator-cli": "^2.6.0",
"@quasar/cli": "^2.2.1",
"@twilio-labs/plugin-dev-phone": "latest",
"@types/node": "^20.3.3",
"@vue/cli": "^5.0.8",
"@webpack-cli/generators": "^3.0.7",
"aigle": "^1.14.1",
"ari-client": "^2.2.0",
"base-x": "^4.0.0",
"blitz": "^2.0.0-beta.29",
"byline": "^5.0.0",
"chokidar-cli": "^3.0.0",
"cjs-to-es6": "^2.0.1",
"colorette": "^2.0.20",
"create-astro": "^3.1.10",
"create-expo-app": "^2.0.3",
"create-feathers": "^5.0.6",
"create-next-app": "latest",
"create-nollup-app": "^0.0.9",
"create-nuxt-app": "^5.0.0",
"create-redwood-app": "^6.1.0",
"create-refine-app": "^1.11.0",
"create-vite": "^4.3.2",
"create-vite-plugin-ssr": "^0.0.293",
"csvtojson": "^2.0.10",
"degit": "^2.8.4",
"deoptigate": "^0.7.1",
"ejs": "^3.1.9",
"electron": "25.2.0",
"eslint": "^8.44.0",
"expo-cli": "^6.3.9",
"express": "^4.18.2",
"express-generator": "^4.16.1",
"fastify-cli": "^5.7.1",
"file-header": "^0.1.1",
"firebase-tools": "^12.4.2",
"fx": "^28.0.0",
"generate-password": "^1.7.0",
"generator-jhipster": "^8.0.0-beta.1",
"generator-jhipster-nodejs": "^2.0.0",
"generator-jhipster-quasar": "^0.14.3",
"http-server": "^14.1.1",
"hygen": "^6.2.11",
"ignite-cli": "^8.8.3",
"json-server": "^0.17.3",
"jsvu": "^2.1.0",
"knex": "^2.4.2",
"lerna": "^7.1.1",
"lodash": "^4.17.21",
"magic-regexp": "^0.7.0",
"mjml": "^4.14.1",
"neovim": "^4.10.1",
"nightmare": "^3.0.2",
"nodemon": "^2.0.22",
"nollup": "^0.21.0",
"onchange": "^7.1.0",
"pg": "8.11.1",
"pkg": "^5.8.1",
"plop": "^3.1.2",
"pnpm": "^8.6.5",
"postgraphile": "^4.13.0",
"prettier": "^2.8.8",
"proxy-kutti": "^1.0.1",
"puppeteer": "^20.7.4",
"puppeteer-core": "^20.7.4",
"qrcode-svg": "^1.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "latest",
"react-native-web": "^0.19.6",
"react-scripts": "^5.0.1",
"redis-commander": "^0.8.0",
"rollup": "^3.26.0",
"runtime-cli": "^3.2.0",
"sass": "^1.63.6",
"serve": "^14.2.0",
"sharp-cli": "^2.1.0",
"sqlite3": "^5.1.6",
"ssh-key-manager": "^0.0.2",
"storybook": "^7.0.24",
"svgo": "^3.0.2",
"sway-workspace-grid": "^0.0.2",
"tailwind-config-viewer": "^1.7.2",
"ts-node": "^10.9.1",
"twilio": "^4.13.0",
"twilio-cli": "^5.5.0",
"typescript": "^5.1.6",
"uglify-js": "^3.17.4",
"uncss": "^0.17.3",
"vite": "^4.3.9",
"webpack-cli": "^5.1.4",
"wscat": "^5.2.0",
"x-ray": "^2.3.4",
"yarn": "^1.22.19",
"yeoman-environment": "^3.19.3",
"zx": "^7.2.2"
}
}

47152
home/.node_modules_mine/yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save